From 32842ff180e61d53745c2e9b814536c0fb3799fc Mon Sep 17 00:00:00 2001 From: unknown unknown Date: Fri, 25 Aug 2023 18:30:31 +0200 Subject: [PATCH 01/10] add msg server create --- api/cosmos/accounts/v1/tx.pulsar.go | 1242 ++++++++++++++++- api/cosmos/accounts/v1/tx_grpc.pb.go | 52 +- proto/cosmos/accounts/v1/accounts.proto | 3 +- proto/cosmos/accounts/v1/query.proto | 3 +- proto/cosmos/accounts/v1/tx.proto | 28 +- scripts/protocgen.sh | 5 +- .../internal/implementation/api_builder.go | 6 + .../internal/implementation/implementation.go | 15 +- .../implementation/implementation_test.go | 31 + .../internal/implementation/protoaccount.go | 17 + x/accounts/keeper.go | 7 +- x/accounts/keeper_test.go | 10 +- x/accounts/msg_server.go | 58 + x/accounts/msg_server_test.go | 30 + x/accounts/v1/tx.pb.go | 682 ++++++++- 15 files changed, 2146 insertions(+), 43 deletions(-) create mode 100644 x/accounts/msg_server.go create mode 100644 x/accounts/msg_server_test.go diff --git a/api/cosmos/accounts/v1/tx.pulsar.go b/api/cosmos/accounts/v1/tx.pulsar.go index c3b7fdab28fc..faa9c20146b4 100644 --- a/api/cosmos/accounts/v1/tx.pulsar.go +++ b/api/cosmos/accounts/v1/tx.pulsar.go @@ -2,11 +2,1052 @@ package accountsv1 import ( + fmt "fmt" + runtime "github.com/cosmos/cosmos-proto/runtime" protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + io "io" reflect "reflect" + sync "sync" ) +var ( + md_MsgCreate protoreflect.MessageDescriptor + fd_MsgCreate_sender protoreflect.FieldDescriptor + fd_MsgCreate_account_type protoreflect.FieldDescriptor + fd_MsgCreate_message protoreflect.FieldDescriptor +) + +func init() { + file_cosmos_accounts_v1_tx_proto_init() + md_MsgCreate = File_cosmos_accounts_v1_tx_proto.Messages().ByName("MsgCreate") + fd_MsgCreate_sender = md_MsgCreate.Fields().ByName("sender") + fd_MsgCreate_account_type = md_MsgCreate.Fields().ByName("account_type") + fd_MsgCreate_message = md_MsgCreate.Fields().ByName("message") +} + +var _ protoreflect.Message = (*fastReflection_MsgCreate)(nil) + +type fastReflection_MsgCreate MsgCreate + +func (x *MsgCreate) ProtoReflect() protoreflect.Message { + return (*fastReflection_MsgCreate)(x) +} + +func (x *MsgCreate) slowProtoReflect() protoreflect.Message { + mi := &file_cosmos_accounts_v1_tx_proto_msgTypes[0] + 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_MsgCreate_messageType fastReflection_MsgCreate_messageType +var _ protoreflect.MessageType = fastReflection_MsgCreate_messageType{} + +type fastReflection_MsgCreate_messageType struct{} + +func (x fastReflection_MsgCreate_messageType) Zero() protoreflect.Message { + return (*fastReflection_MsgCreate)(nil) +} +func (x fastReflection_MsgCreate_messageType) New() protoreflect.Message { + return new(fastReflection_MsgCreate) +} +func (x fastReflection_MsgCreate_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_MsgCreate +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_MsgCreate) Descriptor() protoreflect.MessageDescriptor { + return md_MsgCreate +} + +// 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_MsgCreate) Type() protoreflect.MessageType { + return _fastReflection_MsgCreate_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_MsgCreate) New() protoreflect.Message { + return new(fastReflection_MsgCreate) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_MsgCreate) Interface() protoreflect.ProtoMessage { + return (*MsgCreate)(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_MsgCreate) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if x.Sender != "" { + value := protoreflect.ValueOfString(x.Sender) + if !f(fd_MsgCreate_sender, value) { + return + } + } + if x.AccountType != "" { + value := protoreflect.ValueOfString(x.AccountType) + if !f(fd_MsgCreate_account_type, value) { + return + } + } + if len(x.Message) != 0 { + value := protoreflect.ValueOfBytes(x.Message) + if !f(fd_MsgCreate_message, 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_MsgCreate) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "cosmos.accounts.v1.MsgCreate.sender": + return x.Sender != "" + case "cosmos.accounts.v1.MsgCreate.account_type": + return x.AccountType != "" + case "cosmos.accounts.v1.MsgCreate.message": + return len(x.Message) != 0 + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.v1.MsgCreate")) + } + panic(fmt.Errorf("message cosmos.accounts.v1.MsgCreate 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_MsgCreate) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "cosmos.accounts.v1.MsgCreate.sender": + x.Sender = "" + case "cosmos.accounts.v1.MsgCreate.account_type": + x.AccountType = "" + case "cosmos.accounts.v1.MsgCreate.message": + x.Message = nil + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.v1.MsgCreate")) + } + panic(fmt.Errorf("message cosmos.accounts.v1.MsgCreate 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_MsgCreate) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "cosmos.accounts.v1.MsgCreate.sender": + value := x.Sender + return protoreflect.ValueOfString(value) + case "cosmos.accounts.v1.MsgCreate.account_type": + value := x.AccountType + return protoreflect.ValueOfString(value) + case "cosmos.accounts.v1.MsgCreate.message": + value := x.Message + return protoreflect.ValueOfBytes(value) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.v1.MsgCreate")) + } + panic(fmt.Errorf("message cosmos.accounts.v1.MsgCreate 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_MsgCreate) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "cosmos.accounts.v1.MsgCreate.sender": + x.Sender = value.Interface().(string) + case "cosmos.accounts.v1.MsgCreate.account_type": + x.AccountType = value.Interface().(string) + case "cosmos.accounts.v1.MsgCreate.message": + x.Message = value.Bytes() + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.v1.MsgCreate")) + } + panic(fmt.Errorf("message cosmos.accounts.v1.MsgCreate 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_MsgCreate) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "cosmos.accounts.v1.MsgCreate.sender": + panic(fmt.Errorf("field sender of message cosmos.accounts.v1.MsgCreate is not mutable")) + case "cosmos.accounts.v1.MsgCreate.account_type": + panic(fmt.Errorf("field account_type of message cosmos.accounts.v1.MsgCreate is not mutable")) + case "cosmos.accounts.v1.MsgCreate.message": + panic(fmt.Errorf("field message of message cosmos.accounts.v1.MsgCreate is not mutable")) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.v1.MsgCreate")) + } + panic(fmt.Errorf("message cosmos.accounts.v1.MsgCreate 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_MsgCreate) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "cosmos.accounts.v1.MsgCreate.sender": + return protoreflect.ValueOfString("") + case "cosmos.accounts.v1.MsgCreate.account_type": + return protoreflect.ValueOfString("") + case "cosmos.accounts.v1.MsgCreate.message": + return protoreflect.ValueOfBytes(nil) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.v1.MsgCreate")) + } + panic(fmt.Errorf("message cosmos.accounts.v1.MsgCreate 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_MsgCreate) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in cosmos.accounts.v1.MsgCreate", 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_MsgCreate) 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_MsgCreate) 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_MsgCreate) 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_MsgCreate) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*MsgCreate) + if x == nil { + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: 0, + } + } + options := runtime.SizeInputToOptions(input) + _ = options + var n int + var l int + _ = l + l = len(x.Sender) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + l = len(x.AccountType) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + l = len(x.Message) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + if x.unknownFields != nil { + n += len(x.unknownFields) + } + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: n, + } + } + + marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) { + x := input.Message.Interface().(*MsgCreate) + if x == nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + options := runtime.MarshalInputToOptions(input) + _ = options + size := options.Size(x) + dAtA := make([]byte, size) + i := len(dAtA) + _ = i + var l int + _ = l + if x.unknownFields != nil { + i -= len(x.unknownFields) + copy(dAtA[i:], x.unknownFields) + } + if len(x.Message) > 0 { + i -= len(x.Message) + copy(dAtA[i:], x.Message) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Message))) + i-- + dAtA[i] = 0x1a + } + if len(x.AccountType) > 0 { + i -= len(x.AccountType) + copy(dAtA[i:], x.AccountType) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.AccountType))) + i-- + dAtA[i] = 0x12 + } + if len(x.Sender) > 0 { + i -= len(x.Sender) + copy(dAtA[i:], x.Sender) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Sender))) + 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().(*MsgCreate) + 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: MsgCreate: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: MsgCreate: 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 Sender", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.Sender = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field AccountType", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.AccountType = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Message", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.Message = append(x.Message[:0], dAtA[iNdEx:postIndex]...) + if x.Message == nil { + x.Message = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := runtime.Skip(dAtA[iNdEx:]) + if err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if !options.DiscardUnknown { + x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + } + iNdEx += skippy + } + } + + if iNdEx > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil + } + return &protoiface.Methods{ + NoUnkeyedLiterals: struct{}{}, + Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown, + Size: size, + Marshal: marshal, + Unmarshal: unmarshal, + Merge: nil, + CheckInitialized: nil, + } +} + +var ( + md_MsgCreateResponse protoreflect.MessageDescriptor + fd_MsgCreateResponse_account_address protoreflect.FieldDescriptor + fd_MsgCreateResponse_response protoreflect.FieldDescriptor +) + +func init() { + file_cosmos_accounts_v1_tx_proto_init() + md_MsgCreateResponse = File_cosmos_accounts_v1_tx_proto.Messages().ByName("MsgCreateResponse") + fd_MsgCreateResponse_account_address = md_MsgCreateResponse.Fields().ByName("account_address") + fd_MsgCreateResponse_response = md_MsgCreateResponse.Fields().ByName("response") +} + +var _ protoreflect.Message = (*fastReflection_MsgCreateResponse)(nil) + +type fastReflection_MsgCreateResponse MsgCreateResponse + +func (x *MsgCreateResponse) ProtoReflect() protoreflect.Message { + return (*fastReflection_MsgCreateResponse)(x) +} + +func (x *MsgCreateResponse) slowProtoReflect() protoreflect.Message { + mi := &file_cosmos_accounts_v1_tx_proto_msgTypes[1] + 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_MsgCreateResponse_messageType fastReflection_MsgCreateResponse_messageType +var _ protoreflect.MessageType = fastReflection_MsgCreateResponse_messageType{} + +type fastReflection_MsgCreateResponse_messageType struct{} + +func (x fastReflection_MsgCreateResponse_messageType) Zero() protoreflect.Message { + return (*fastReflection_MsgCreateResponse)(nil) +} +func (x fastReflection_MsgCreateResponse_messageType) New() protoreflect.Message { + return new(fastReflection_MsgCreateResponse) +} +func (x fastReflection_MsgCreateResponse_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_MsgCreateResponse +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_MsgCreateResponse) Descriptor() protoreflect.MessageDescriptor { + return md_MsgCreateResponse +} + +// 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_MsgCreateResponse) Type() protoreflect.MessageType { + return _fastReflection_MsgCreateResponse_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_MsgCreateResponse) New() protoreflect.Message { + return new(fastReflection_MsgCreateResponse) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_MsgCreateResponse) Interface() protoreflect.ProtoMessage { + return (*MsgCreateResponse)(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_MsgCreateResponse) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if x.AccountAddress != "" { + value := protoreflect.ValueOfString(x.AccountAddress) + if !f(fd_MsgCreateResponse_account_address, value) { + return + } + } + if len(x.Response) != 0 { + value := protoreflect.ValueOfBytes(x.Response) + if !f(fd_MsgCreateResponse_response, 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_MsgCreateResponse) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "cosmos.accounts.v1.MsgCreateResponse.account_address": + return x.AccountAddress != "" + case "cosmos.accounts.v1.MsgCreateResponse.response": + return len(x.Response) != 0 + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.v1.MsgCreateResponse")) + } + panic(fmt.Errorf("message cosmos.accounts.v1.MsgCreateResponse 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_MsgCreateResponse) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "cosmos.accounts.v1.MsgCreateResponse.account_address": + x.AccountAddress = "" + case "cosmos.accounts.v1.MsgCreateResponse.response": + x.Response = nil + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.v1.MsgCreateResponse")) + } + panic(fmt.Errorf("message cosmos.accounts.v1.MsgCreateResponse 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_MsgCreateResponse) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "cosmos.accounts.v1.MsgCreateResponse.account_address": + value := x.AccountAddress + return protoreflect.ValueOfString(value) + case "cosmos.accounts.v1.MsgCreateResponse.response": + value := x.Response + return protoreflect.ValueOfBytes(value) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.v1.MsgCreateResponse")) + } + panic(fmt.Errorf("message cosmos.accounts.v1.MsgCreateResponse 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_MsgCreateResponse) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "cosmos.accounts.v1.MsgCreateResponse.account_address": + x.AccountAddress = value.Interface().(string) + case "cosmos.accounts.v1.MsgCreateResponse.response": + x.Response = value.Bytes() + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.v1.MsgCreateResponse")) + } + panic(fmt.Errorf("message cosmos.accounts.v1.MsgCreateResponse 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_MsgCreateResponse) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "cosmos.accounts.v1.MsgCreateResponse.account_address": + panic(fmt.Errorf("field account_address of message cosmos.accounts.v1.MsgCreateResponse is not mutable")) + case "cosmos.accounts.v1.MsgCreateResponse.response": + panic(fmt.Errorf("field response of message cosmos.accounts.v1.MsgCreateResponse is not mutable")) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.v1.MsgCreateResponse")) + } + panic(fmt.Errorf("message cosmos.accounts.v1.MsgCreateResponse 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_MsgCreateResponse) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "cosmos.accounts.v1.MsgCreateResponse.account_address": + return protoreflect.ValueOfString("") + case "cosmos.accounts.v1.MsgCreateResponse.response": + return protoreflect.ValueOfBytes(nil) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.v1.MsgCreateResponse")) + } + panic(fmt.Errorf("message cosmos.accounts.v1.MsgCreateResponse 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_MsgCreateResponse) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in cosmos.accounts.v1.MsgCreateResponse", 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_MsgCreateResponse) 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_MsgCreateResponse) 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_MsgCreateResponse) 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_MsgCreateResponse) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*MsgCreateResponse) + if x == nil { + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: 0, + } + } + options := runtime.SizeInputToOptions(input) + _ = options + var n int + var l int + _ = l + l = len(x.AccountAddress) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + l = len(x.Response) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + if x.unknownFields != nil { + n += len(x.unknownFields) + } + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: n, + } + } + + marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) { + x := input.Message.Interface().(*MsgCreateResponse) + if x == nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + options := runtime.MarshalInputToOptions(input) + _ = options + size := options.Size(x) + dAtA := make([]byte, size) + i := len(dAtA) + _ = i + var l int + _ = l + if x.unknownFields != nil { + i -= len(x.unknownFields) + copy(dAtA[i:], x.unknownFields) + } + if len(x.Response) > 0 { + i -= len(x.Response) + copy(dAtA[i:], x.Response) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Response))) + i-- + dAtA[i] = 0x12 + } + if len(x.AccountAddress) > 0 { + i -= len(x.AccountAddress) + copy(dAtA[i:], x.AccountAddress) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.AccountAddress))) + 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().(*MsgCreateResponse) + 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: MsgCreateResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: MsgCreateResponse: 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 AccountAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.AccountAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Response", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.Response = append(x.Response[:0], dAtA[iNdEx:postIndex]...) + if x.Response == nil { + x.Response = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := runtime.Skip(dAtA[iNdEx:]) + if err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if !options.DiscardUnknown { + x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + } + iNdEx += skippy + } + } + + if iNdEx > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil + } + return &protoiface.Methods{ + NoUnkeyedLiterals: struct{}{}, + Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown, + Size: size, + Marshal: marshal, + Unmarshal: unmarshal, + Merge: nil, + CheckInitialized: nil, + } +} + // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.27.0 @@ -20,31 +1061,169 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) +// MsgCreate defines the Create request type for the Msg/Create RPC method. +type MsgCreate struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // sender is the address of the sender of this message. + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` + // account_type is the type of the account to be created. + AccountType string `protobuf:"bytes,2,opt,name=account_type,json=accountType,proto3" json:"account_type,omitempty"` + // message is the message to be sent to the account, it's up to the account + // implementation to decide what encoding format should be used to interpret + // this message. + Message []byte `protobuf:"bytes,3,opt,name=message,proto3" json:"message,omitempty"` +} + +func (x *MsgCreate) Reset() { + *x = MsgCreate{} + if protoimpl.UnsafeEnabled { + mi := &file_cosmos_accounts_v1_tx_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *MsgCreate) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*MsgCreate) ProtoMessage() {} + +// Deprecated: Use MsgCreate.ProtoReflect.Descriptor instead. +func (*MsgCreate) Descriptor() ([]byte, []int) { + return file_cosmos_accounts_v1_tx_proto_rawDescGZIP(), []int{0} +} + +func (x *MsgCreate) GetSender() string { + if x != nil { + return x.Sender + } + return "" +} + +func (x *MsgCreate) GetAccountType() string { + if x != nil { + return x.AccountType + } + return "" +} + +func (x *MsgCreate) GetMessage() []byte { + if x != nil { + return x.Message + } + return nil +} + +// MsgCreateResponse defines the Create response type for the Msg/Create RPC method. +type MsgCreateResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // account_address is the address of the newly created account. + AccountAddress string `protobuf:"bytes,1,opt,name=account_address,json=accountAddress,proto3" json:"account_address,omitempty"` + // response is the response returned by the account implementation. + Response []byte `protobuf:"bytes,2,opt,name=response,proto3" json:"response,omitempty"` +} + +func (x *MsgCreateResponse) Reset() { + *x = MsgCreateResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_cosmos_accounts_v1_tx_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *MsgCreateResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*MsgCreateResponse) ProtoMessage() {} + +// Deprecated: Use MsgCreateResponse.ProtoReflect.Descriptor instead. +func (*MsgCreateResponse) Descriptor() ([]byte, []int) { + return file_cosmos_accounts_v1_tx_proto_rawDescGZIP(), []int{1} +} + +func (x *MsgCreateResponse) GetAccountAddress() string { + if x != nil { + return x.AccountAddress + } + return "" +} + +func (x *MsgCreateResponse) GetResponse() []byte { + if x != nil { + return x.Response + } + return nil +} + var File_cosmos_accounts_v1_tx_proto protoreflect.FileDescriptor var file_cosmos_accounts_v1_tx_proto_rawDesc = []byte{ 0x0a, 0x1b, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2f, 0x76, 0x31, 0x2f, 0x74, 0x78, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x12, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2e, 0x76, - 0x31, 0x32, 0x05, 0x0a, 0x03, 0x4d, 0x73, 0x67, 0x42, 0xbb, 0x01, 0x0a, 0x16, 0x63, 0x6f, 0x6d, + 0x31, 0x22, 0x60, 0x0a, 0x09, 0x4d, 0x73, 0x67, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x12, 0x16, + 0x0a, 0x06, 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, + 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x12, 0x21, 0x0a, 0x0c, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, + 0x74, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x61, 0x63, + 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, + 0x73, 0x61, 0x67, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, + 0x61, 0x67, 0x65, 0x22, 0x58, 0x0a, 0x11, 0x4d, 0x73, 0x67, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x27, 0x0a, 0x0f, 0x61, 0x63, 0x63, 0x6f, + 0x75, 0x6e, 0x74, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x0e, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, + 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x0c, 0x52, 0x08, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0x55, 0x0a, + 0x03, 0x4d, 0x73, 0x67, 0x12, 0x4e, 0x0a, 0x06, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x12, 0x1d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, - 0x2e, 0x76, 0x31, 0x42, 0x07, 0x54, 0x78, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x2e, - 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, 0x76, 0x31, 0x3b, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x76, 0x31, 0xa2, 0x02, - 0x03, 0x43, 0x41, 0x58, 0xaa, 0x02, 0x12, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x63, - 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x12, 0x43, 0x6f, 0x73, 0x6d, - 0x6f, 0x73, 0x5c, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x5c, 0x56, 0x31, 0xe2, 0x02, - 0x1e, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, - 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, - 0x02, 0x14, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x3a, 0x3a, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, - 0x74, 0x73, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var file_cosmos_accounts_v1_tx_proto_goTypes = []interface{}{} + 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x1a, 0x25, 0x2e, + 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2e, + 0x76, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x42, 0xbb, 0x01, 0x0a, 0x16, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, + 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2e, 0x76, 0x31, 0x42, + 0x07, 0x54, 0x78, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x2e, 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, 0x76, 0x31, 0x3b, + 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x41, 0x58, + 0xaa, 0x02, 0x12, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, + 0x74, 0x73, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x12, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x41, + 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x1e, 0x43, 0x6f, 0x73, + 0x6d, 0x6f, 0x73, 0x5c, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x5c, 0x56, 0x31, 0x5c, + 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x14, 0x43, 0x6f, + 0x73, 0x6d, 0x6f, 0x73, 0x3a, 0x3a, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x3a, 0x3a, + 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_cosmos_accounts_v1_tx_proto_rawDescOnce sync.Once + file_cosmos_accounts_v1_tx_proto_rawDescData = file_cosmos_accounts_v1_tx_proto_rawDesc +) + +func file_cosmos_accounts_v1_tx_proto_rawDescGZIP() []byte { + file_cosmos_accounts_v1_tx_proto_rawDescOnce.Do(func() { + file_cosmos_accounts_v1_tx_proto_rawDescData = protoimpl.X.CompressGZIP(file_cosmos_accounts_v1_tx_proto_rawDescData) + }) + return file_cosmos_accounts_v1_tx_proto_rawDescData +} + +var file_cosmos_accounts_v1_tx_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_cosmos_accounts_v1_tx_proto_goTypes = []interface{}{ + (*MsgCreate)(nil), // 0: cosmos.accounts.v1.MsgCreate + (*MsgCreateResponse)(nil), // 1: cosmos.accounts.v1.MsgCreateResponse +} var file_cosmos_accounts_v1_tx_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: cosmos.accounts.v1.Msg.Create:input_type -> cosmos.accounts.v1.MsgCreate + 1, // 1: cosmos.accounts.v1.Msg.Create:output_type -> cosmos.accounts.v1.MsgCreateResponse + 1, // [1:2] is the sub-list for method output_type + 0, // [0:1] 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 @@ -55,18 +1234,45 @@ func file_cosmos_accounts_v1_tx_proto_init() { if File_cosmos_accounts_v1_tx_proto != nil { return } + if !protoimpl.UnsafeEnabled { + file_cosmos_accounts_v1_tx_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*MsgCreate); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_cosmos_accounts_v1_tx_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*MsgCreateResponse); 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{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_cosmos_accounts_v1_tx_proto_rawDesc, NumEnums: 0, - NumMessages: 0, + NumMessages: 2, NumExtensions: 0, NumServices: 1, }, GoTypes: file_cosmos_accounts_v1_tx_proto_goTypes, DependencyIndexes: file_cosmos_accounts_v1_tx_proto_depIdxs, + MessageInfos: file_cosmos_accounts_v1_tx_proto_msgTypes, }.Build() File_cosmos_accounts_v1_tx_proto = out.File file_cosmos_accounts_v1_tx_proto_rawDesc = nil diff --git a/api/cosmos/accounts/v1/tx_grpc.pb.go b/api/cosmos/accounts/v1/tx_grpc.pb.go index 984efbddb393..fb5722bc8e7b 100644 --- a/api/cosmos/accounts/v1/tx_grpc.pb.go +++ b/api/cosmos/accounts/v1/tx_grpc.pb.go @@ -7,7 +7,10 @@ package accountsv1 import ( + context "context" grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" ) // This is a compile-time assertion to ensure that this generated file @@ -15,12 +18,16 @@ import ( // Requires gRPC-Go v1.32.0 or later. const _ = grpc.SupportPackageIsVersion7 -const () +const ( + Msg_Create_FullMethodName = "/cosmos.accounts.v1.Msg/Create" +) // MsgClient is the client API for Msg service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. type MsgClient interface { + // Create creates a new account in the chain. + Create(ctx context.Context, in *MsgCreate, opts ...grpc.CallOption) (*MsgCreateResponse, error) } type msgClient struct { @@ -31,10 +38,21 @@ func NewMsgClient(cc grpc.ClientConnInterface) MsgClient { return &msgClient{cc} } +func (c *msgClient) Create(ctx context.Context, in *MsgCreate, opts ...grpc.CallOption) (*MsgCreateResponse, error) { + out := new(MsgCreateResponse) + err := c.cc.Invoke(ctx, Msg_Create_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // MsgServer is the server API for Msg service. // All implementations must embed UnimplementedMsgServer // for forward compatibility type MsgServer interface { + // Create creates a new account in the chain. + Create(context.Context, *MsgCreate) (*MsgCreateResponse, error) mustEmbedUnimplementedMsgServer() } @@ -42,6 +60,9 @@ type MsgServer interface { type UnimplementedMsgServer struct { } +func (UnimplementedMsgServer) Create(context.Context, *MsgCreate) (*MsgCreateResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Create not implemented") +} func (UnimplementedMsgServer) mustEmbedUnimplementedMsgServer() {} // UnsafeMsgServer may be embedded to opt out of forward compatibility for this service. @@ -55,13 +76,36 @@ func RegisterMsgServer(s grpc.ServiceRegistrar, srv MsgServer) { s.RegisterService(&Msg_ServiceDesc, srv) } +func _Msg_Create_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgCreate) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).Create(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Msg_Create_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).Create(ctx, req.(*MsgCreate)) + } + return interceptor(ctx, in, info, handler) +} + // Msg_ServiceDesc is the grpc.ServiceDesc for Msg service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) var Msg_ServiceDesc = grpc.ServiceDesc{ ServiceName: "cosmos.accounts.v1.Msg", HandlerType: (*MsgServer)(nil), - Methods: []grpc.MethodDesc{}, - Streams: []grpc.StreamDesc{}, - Metadata: "cosmos/accounts/v1/tx.proto", + Methods: []grpc.MethodDesc{ + { + MethodName: "Create", + Handler: _Msg_Create_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "cosmos/accounts/v1/tx.proto", } diff --git a/proto/cosmos/accounts/v1/accounts.proto b/proto/cosmos/accounts/v1/accounts.proto index 57b598904415..58d35ef41eef 100644 --- a/proto/cosmos/accounts/v1/accounts.proto +++ b/proto/cosmos/accounts/v1/accounts.proto @@ -1,4 +1,5 @@ syntax = "proto3"; package cosmos.accounts.v1; -option go_package = "cosmossdk.io/x/accounts/v1"; + +option go_package = "cosmossdk.io/x/accounts/v1"; diff --git a/proto/cosmos/accounts/v1/query.proto b/proto/cosmos/accounts/v1/query.proto index e6aaaa871e7b..6d163414984d 100644 --- a/proto/cosmos/accounts/v1/query.proto +++ b/proto/cosmos/accounts/v1/query.proto @@ -1,7 +1,8 @@ syntax = "proto3"; package cosmos.accounts.v1; -option go_package = "cosmossdk.io/x/accounts/v1"; + +option go_package = "cosmossdk.io/x/accounts/v1"; // Query defines the Query service for the x/accounts module. service Query {} diff --git a/proto/cosmos/accounts/v1/tx.proto b/proto/cosmos/accounts/v1/tx.proto index 9a266f2b3db3..a03a22179544 100644 --- a/proto/cosmos/accounts/v1/tx.proto +++ b/proto/cosmos/accounts/v1/tx.proto @@ -1,7 +1,31 @@ syntax = "proto3"; package cosmos.accounts.v1; -option go_package = "cosmossdk.io/x/accounts/v1"; + +option go_package = "cosmossdk.io/x/accounts/v1"; // Msg defines the Msg service for the x/accounts module. -service Msg {} +service Msg { + // Create creates a new account in the chain. + rpc Create(MsgCreate) returns (MsgCreateResponse); +} + +// MsgCreate defines the Create request type for the Msg/Create RPC method. +message MsgCreate { + // sender is the address of the sender of this message. + string sender = 1; + // account_type is the type of the account to be created. + string account_type = 2; + // message is the message to be sent to the account, it's up to the account + // implementation to decide what encoding format should be used to interpret + // this message. + bytes message = 3; +} + +// MsgCreateResponse defines the Create response type for the Msg/Create RPC method. +message MsgCreateResponse { + // account_address is the address of the newly created account. + string account_address = 1; + // response is the response returned by the account implementation. + bytes response = 2; +} diff --git a/scripts/protocgen.sh b/scripts/protocgen.sh index bd4193388c4b..5ed5f7da89af 100755 --- a/scripts/protocgen.sh +++ b/scripts/protocgen.sh @@ -4,6 +4,9 @@ # docker build --pull --rm -f "contrib/devtools/Dockerfile" -t cosmossdk-proto:latest "contrib/devtools" # docker run --rm -v $(pwd):/workspace --workdir /workspace cosmossdk-proto sh ./scripts/protocgen.sh +echo "Formatting protobuf files" +find ./ -name "*.proto" -exec clang-format -i {} \; + set -e echo "Generating gogo proto code" @@ -36,5 +39,3 @@ go mod tidy ./scripts/protocgen-pulsar.sh -echo "Formatting protobuf files" -find ./ -name "*.proto" -exec clang-format -i {} \; diff --git a/x/accounts/internal/implementation/api_builder.go b/x/accounts/internal/implementation/api_builder.go index 51fb8aa4b690..de887373a54f 100644 --- a/x/accounts/internal/implementation/api_builder.go +++ b/x/accounts/internal/implementation/api_builder.go @@ -25,6 +25,12 @@ type InitBuilder struct { // Although the function here is defined to take an any, the smart account will work // with a typed version of it. handler func(ctx context.Context, initRequest any) (initResponse any, err error) + + // decodeRequest is the function that will be used to decode the init request from bytes. + decodeRequest func([]byte) (any, error) + + // encodeResponse is the function that will be used to encode the init response to bytes. + encodeResponse func(any) ([]byte, error) } // makeHandler returns the handler function that will be called when the smart account is initialized. diff --git a/x/accounts/internal/implementation/implementation.go b/x/accounts/internal/implementation/implementation.go index f8fd780a2e67..4ec274f9487c 100644 --- a/x/accounts/internal/implementation/implementation.go +++ b/x/accounts/internal/implementation/implementation.go @@ -28,9 +28,11 @@ func NewImplementation(account Account) (Implementation, error) { return Implementation{}, err } return Implementation{ - Init: initHandler, - Execute: executeHandler, - Query: queryHandler, + Init: initHandler, + Execute: executeHandler, + Query: queryHandler, + DecodeInitRequest: ir.decodeRequest, + EncodeInitResponse: ir.encodeResponse, }, nil } @@ -43,4 +45,11 @@ type Implementation struct { Execute func(ctx context.Context, msg any) (resp any, err error) // Query defines the query handler for the smart account. Query func(ctx context.Context, msg any) (resp any, err error) + + // Schema + + // DecodeInitRequest decodes an init request coming from the message server. + DecodeInitRequest func([]byte) (any, error) + // EncodeInitResponse encodes an init response to be sent back from the message server. + EncodeInitResponse func(any) ([]byte, error) } diff --git a/x/accounts/internal/implementation/implementation_test.go b/x/accounts/internal/implementation/implementation_test.go index 6b87cb9b8a9f..20c3c814bd9c 100644 --- a/x/accounts/internal/implementation/implementation_test.go +++ b/x/accounts/internal/implementation/implementation_test.go @@ -5,6 +5,9 @@ import ( "testing" "github.com/stretchr/testify/require" + "google.golang.org/protobuf/encoding/protojson" + "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/reflect/protoreflect" "google.golang.org/protobuf/types/known/wrapperspb" ) @@ -63,4 +66,32 @@ func TestImplementation(t *testing.T) { _, err = impl.Init(ctx, "test") require.ErrorIs(t, err, errInvalidMessage) }) + + // schemas + t.Run("decode init request - ok", func(t *testing.T) { + want := &wrapperspb.StringValue{Value: "test"} + req, err := protojson.Marshal(want) + require.NoError(t, err) + + got, err := impl.DecodeInitRequest(req) + require.NoError(t, err) + require.True(t, proto.Equal(want, got.(protoreflect.ProtoMessage))) + }) + + t.Run("encode init response - ok", func(t *testing.T) { + want := &wrapperspb.StringValue{Value: "test"} + + gotBytes, err := impl.EncodeInitResponse(want) + require.NoError(t, err) + + wantBytes, err := protojson.Marshal(want) + require.NoError(t, err) + + require.Equal(t, wantBytes, gotBytes) + }) + + t.Run("decode init response - invalid message", func(t *testing.T) { + _, err := impl.EncodeInitResponse([]byte("invalid")) + require.ErrorIs(t, err, errInvalidMessage) + }) } diff --git a/x/accounts/internal/implementation/protoaccount.go b/x/accounts/internal/implementation/protoaccount.go index 19d72597f1a1..c02dd9658945 100644 --- a/x/accounts/internal/implementation/protoaccount.go +++ b/x/accounts/internal/implementation/protoaccount.go @@ -4,6 +4,7 @@ import ( "context" "fmt" + "google.golang.org/protobuf/encoding/protojson" "google.golang.org/protobuf/reflect/protoreflect" ) @@ -18,6 +19,8 @@ func RegisterInitHandler[ Req any, ProtoReq ProtoMsg[Req], Resp any, ProtoResp ProtoMsg[Resp], ](router *InitBuilder, handler func(ctx context.Context, req ProtoReq) (ProtoResp, error)) { reqName := ProtoReq(new(Req)).ProtoReflect().Descriptor().FullName() + respName := ProtoResp(new(Resp)).ProtoReflect().Descriptor().FullName() + router.handler = func(ctx context.Context, initRequest any) (initResponse any, err error) { concrete, ok := initRequest.(ProtoReq) if !ok { @@ -25,6 +28,20 @@ func RegisterInitHandler[ } return handler(ctx, concrete) } + + router.decodeRequest = func(b []byte) (any, error) { + req := new(Req) + err := protojson.Unmarshal(b, ProtoReq(req)) + return req, err + } + + router.encodeResponse = func(resp any) ([]byte, error) { + protoResp, ok := resp.(ProtoResp) + if !ok { + return nil, fmt.Errorf("%w: wanted %s, got %T", errInvalidMessage, respName, resp) + } + return protojson.Marshal(protoResp) + } } // RegisterExecuteHandler registers an execution handler for a smart account that uses protobuf. diff --git a/x/accounts/keeper.go b/x/accounts/keeper.go index f705e95dea26..d95894ee8cd8 100644 --- a/x/accounts/keeper.go +++ b/x/accounts/keeper.go @@ -8,6 +8,7 @@ import ( "fmt" "cosmossdk.io/collections" + "cosmossdk.io/core/address" "cosmossdk.io/core/store" "cosmossdk.io/x/accounts/internal/implementation" ) @@ -21,10 +22,11 @@ var ( AccountNumberKey = collections.NewPrefix(1) ) -func NewKeeper(ss store.KVStoreService, accounts map[string]implementation.Account) (Keeper, error) { +func NewKeeper(ss store.KVStoreService, addressCodec address.Codec, accounts map[string]implementation.Account) (Keeper, error) { sb := collections.NewSchemaBuilder(ss) keeper := Keeper{ storeService: ss, + addressCodec: addressCodec, accounts: map[string]implementation.Implementation{}, AccountNumber: collections.NewSequence(sb, AccountNumberKey, "account_number"), AccountsByType: collections.NewMap(sb, AccountTypeKeyPrefix, "accounts_by_type", collections.BytesKey, collections.StringValue), @@ -51,11 +53,12 @@ type Keeper struct { accounts map[string]implementation.Implementation + addressCodec address.Codec + // Schema is the schema for the module. Schema collections.Schema // AccountNumber is the last global account number. AccountNumber collections.Sequence - // AccountsByType maps account address to their implementation. AccountsByType collections.Map[[]byte, string] } diff --git a/x/accounts/keeper_test.go b/x/accounts/keeper_test.go index ab5beffe704b..23f3431c2451 100644 --- a/x/accounts/keeper_test.go +++ b/x/accounts/keeper_test.go @@ -4,6 +4,7 @@ import ( "context" "testing" + "cosmossdk.io/core/address" "github.com/stretchr/testify/require" "google.golang.org/protobuf/types/known/emptypb" @@ -12,10 +13,17 @@ import ( "cosmossdk.io/x/accounts/internal/implementation" ) +var _ address.Codec = (*addressCodec)(nil) + +type addressCodec struct{} + +func (a addressCodec) StringToBytes(text string) ([]byte, error) { return []byte(text), nil } +func (a addressCodec) BytesToString(bz []byte) (string, error) { return string(bz), nil } + func newKeeper(t *testing.T, accounts map[string]implementation.Account) (Keeper, context.Context) { t.Helper() ss, ctx := colltest.MockStore() - m, err := NewKeeper(ss, accounts) + m, err := NewKeeper(ss, addressCodec{}, accounts) require.NoError(t, err) return m, ctx } diff --git a/x/accounts/msg_server.go b/x/accounts/msg_server.go new file mode 100644 index 000000000000..dd1aefac790d --- /dev/null +++ b/x/accounts/msg_server.go @@ -0,0 +1,58 @@ +package accounts + +import ( + "context" + + v1 "cosmossdk.io/x/accounts/v1" +) + +var _ v1.MsgServer = msgServer{} + +func NewMsgServer(k Keeper) v1.MsgServer { + return &msgServer{k} +} + +type msgServer struct { + k Keeper +} + +func (m msgServer) Create(ctx context.Context, request *v1.MsgCreate) (*v1.MsgCreateResponse, error) { + creator, err := m.k.addressCodec.StringToBytes(request.Sender) + if err != nil { + return nil, err + } + + impl, err := m.k.getImplementation(request.AccountType) + if err != nil { + return nil, err + } + + // decode message bytes into the concrete boxed message type + msg, err := impl.DecodeInitRequest(request.Message) + if err != nil { + return nil, err + } + + // run account creation logic + resp, accAddr, err := m.k.Create(ctx, request.AccountType, creator, msg) + if err != nil { + return nil, err + } + + // encode the response + respBytes, err := impl.EncodeInitResponse(resp) + if err != nil { + return nil, err + } + + // encode the address + accAddrString, err := m.k.addressCodec.BytesToString(accAddr) + if err != nil { + return nil, err + } + + return &v1.MsgCreateResponse{ + AccountAddress: accAddrString, + Response: respBytes, + }, nil +} diff --git a/x/accounts/msg_server_test.go b/x/accounts/msg_server_test.go new file mode 100644 index 000000000000..eca35b8dd6f8 --- /dev/null +++ b/x/accounts/msg_server_test.go @@ -0,0 +1,30 @@ +package accounts + +import ( + "testing" + + "cosmossdk.io/x/accounts/internal/implementation" + v1 "cosmossdk.io/x/accounts/v1" + "github.com/stretchr/testify/require" + "google.golang.org/protobuf/encoding/protojson" + "google.golang.org/protobuf/types/known/emptypb" +) + +func TestMsgServer_Create(t *testing.T) { + k, ctx := newKeeper(t, map[string]implementation.Account{ + "test": TestAccount{}, + }) + + s := NewMsgServer(k) + + initMsg, err := protojson.Marshal(&emptypb.Empty{}) + require.NoError(t, err) + + resp, err := s.Create(ctx, &v1.MsgCreate{ + Sender: "sender", + AccountType: "test", + Message: initMsg, + }) + require.NoError(t, err) + require.NotNil(t, resp) +} diff --git a/x/accounts/v1/tx.pb.go b/x/accounts/v1/tx.pb.go index 2b9a2697e2a3..961d81a81613 100644 --- a/x/accounts/v1/tx.pb.go +++ b/x/accounts/v1/tx.pb.go @@ -9,7 +9,11 @@ import ( grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" math "math" + math_bits "math/bits" ) // Reference imports to suppress errors if they are not otherwise used. @@ -23,18 +27,153 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package +// MsgCreate defines the Create request type for the Msg/Create RPC method. +type MsgCreate struct { + // sender is the address of the sender of this message. + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` + // account_type is the type of the account to be created. + AccountType string `protobuf:"bytes,2,opt,name=account_type,json=accountType,proto3" json:"account_type,omitempty"` + // message is the message to be sent to the account, it's up to the account + // implementation to decide what encoding format should be used to interpret + // this message. + Message []byte `protobuf:"bytes,3,opt,name=message,proto3" json:"message,omitempty"` +} + +func (m *MsgCreate) Reset() { *m = MsgCreate{} } +func (m *MsgCreate) String() string { return proto.CompactTextString(m) } +func (*MsgCreate) ProtoMessage() {} +func (*MsgCreate) Descriptor() ([]byte, []int) { + return fileDescriptor_29c2b6d8a13d4189, []int{0} +} +func (m *MsgCreate) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgCreate) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgCreate.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 *MsgCreate) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCreate.Merge(m, src) +} +func (m *MsgCreate) XXX_Size() int { + return m.Size() +} +func (m *MsgCreate) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCreate.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgCreate proto.InternalMessageInfo + +func (m *MsgCreate) GetSender() string { + if m != nil { + return m.Sender + } + return "" +} + +func (m *MsgCreate) GetAccountType() string { + if m != nil { + return m.AccountType + } + return "" +} + +func (m *MsgCreate) GetMessage() []byte { + if m != nil { + return m.Message + } + return nil +} + +// MsgCreateResponse defines the Create response type for the Msg/Create RPC method. +type MsgCreateResponse struct { + // account_address is the address of the newly created account. + AccountAddress string `protobuf:"bytes,1,opt,name=account_address,json=accountAddress,proto3" json:"account_address,omitempty"` + // response is the response returned by the account implementation. + Response []byte `protobuf:"bytes,2,opt,name=response,proto3" json:"response,omitempty"` +} + +func (m *MsgCreateResponse) Reset() { *m = MsgCreateResponse{} } +func (m *MsgCreateResponse) String() string { return proto.CompactTextString(m) } +func (*MsgCreateResponse) ProtoMessage() {} +func (*MsgCreateResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_29c2b6d8a13d4189, []int{1} +} +func (m *MsgCreateResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgCreateResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgCreateResponse.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 *MsgCreateResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCreateResponse.Merge(m, src) +} +func (m *MsgCreateResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgCreateResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCreateResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgCreateResponse proto.InternalMessageInfo + +func (m *MsgCreateResponse) GetAccountAddress() string { + if m != nil { + return m.AccountAddress + } + return "" +} + +func (m *MsgCreateResponse) GetResponse() []byte { + if m != nil { + return m.Response + } + return nil +} + +func init() { + proto.RegisterType((*MsgCreate)(nil), "cosmos.accounts.v1.MsgCreate") + proto.RegisterType((*MsgCreateResponse)(nil), "cosmos.accounts.v1.MsgCreateResponse") +} + func init() { proto.RegisterFile("cosmos/accounts/v1/tx.proto", fileDescriptor_29c2b6d8a13d4189) } var fileDescriptor_29c2b6d8a13d4189 = []byte{ - // 117 bytes of a gzipped FileDescriptorProto + // 259 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4e, 0xce, 0x2f, 0xce, 0xcd, 0x2f, 0xd6, 0x4f, 0x4c, 0x4e, 0xce, 0x2f, 0xcd, 0x2b, 0x29, 0xd6, 0x2f, 0x33, 0xd4, 0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x82, 0x48, 0xea, 0xc1, 0x24, 0xf5, 0xca, - 0x0c, 0x8d, 0x58, 0xb9, 0x98, 0x7d, 0x8b, 0xd3, 0x9d, 0x4c, 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, 0x0a, 0xa2, 0xa9, 0x38, 0x25, 0x5b, 0x2f, 0x33, 0x5f, 0xbf, 0x02, - 0xd9, 0xe4, 0x24, 0x36, 0xb0, 0xb9, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0xaf, 0x3e, 0xfb, - 0xb6, 0x76, 0x00, 0x00, 0x00, + 0x0c, 0x95, 0x12, 0xb8, 0x38, 0x7d, 0x8b, 0xd3, 0x9d, 0x8b, 0x52, 0x13, 0x4b, 0x52, 0x85, 0xc4, + 0xb8, 0xd8, 0x8a, 0x53, 0xf3, 0x52, 0x52, 0x8b, 0x24, 0x18, 0x15, 0x18, 0x35, 0x38, 0x83, 0xa0, + 0x3c, 0x21, 0x45, 0x2e, 0x1e, 0xa8, 0x9e, 0xf8, 0x92, 0xca, 0x82, 0x54, 0x09, 0x26, 0xb0, 0x2c, + 0x37, 0x54, 0x2c, 0xa4, 0xb2, 0x20, 0x55, 0x48, 0x82, 0x8b, 0x3d, 0x37, 0xb5, 0xb8, 0x38, 0x31, + 0x3d, 0x55, 0x82, 0x59, 0x81, 0x51, 0x83, 0x27, 0x08, 0xc6, 0x55, 0x8a, 0xe0, 0x12, 0x84, 0xdb, + 0x10, 0x94, 0x5a, 0x5c, 0x90, 0x9f, 0x57, 0x9c, 0x2a, 0xa4, 0xce, 0xc5, 0x0f, 0x33, 0x31, 0x31, + 0x25, 0xa5, 0x28, 0xb5, 0xb8, 0x18, 0x6a, 0x25, 0x1f, 0x54, 0xd8, 0x11, 0x22, 0x2a, 0x24, 0xc5, + 0xc5, 0x51, 0x04, 0xd5, 0x04, 0xb6, 0x96, 0x27, 0x08, 0xce, 0x37, 0x0a, 0xe5, 0x62, 0xf6, 0x2d, + 0x4e, 0x17, 0xf2, 0xe3, 0x62, 0x83, 0xba, 0x5f, 0x56, 0x0f, 0xd3, 0x87, 0x7a, 0x70, 0xcb, 0xa5, + 0x54, 0xf1, 0x4a, 0xc3, 0xdc, 0xe6, 0x64, 0x72, 0xe2, 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, + 0x0f, 0x1e, 0xc9, 0x31, 0x4e, 0x78, 0x2c, 0xc7, 0x70, 0xe1, 0xb1, 0x1c, 0xc3, 0x8d, 0xc7, 0x72, + 0x0c, 0x51, 0x52, 0x10, 0xfd, 0xc5, 0x29, 0xd9, 0x7a, 0x99, 0xf9, 0xfa, 0x15, 0xc8, 0xa1, 0x9c, + 0xc4, 0x06, 0x0e, 0x63, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0x42, 0x72, 0x84, 0xc2, 0x82, + 0x01, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -49,6 +188,8 @@ const _ = grpc.SupportPackageIsVersion4 // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. type MsgClient interface { + // Create creates a new account in the chain. + Create(ctx context.Context, in *MsgCreate, opts ...grpc.CallOption) (*MsgCreateResponse, error) } type msgClient struct { @@ -59,22 +200,545 @@ func NewMsgClient(cc grpc1.ClientConn) MsgClient { return &msgClient{cc} } +func (c *msgClient) Create(ctx context.Context, in *MsgCreate, opts ...grpc.CallOption) (*MsgCreateResponse, error) { + out := new(MsgCreateResponse) + err := c.cc.Invoke(ctx, "/cosmos.accounts.v1.Msg/Create", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // MsgServer is the server API for Msg service. type MsgServer interface { + // Create creates a new account in the chain. + Create(context.Context, *MsgCreate) (*MsgCreateResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. type UnimplementedMsgServer struct { } +func (*UnimplementedMsgServer) Create(ctx context.Context, req *MsgCreate) (*MsgCreateResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Create not implemented") +} + func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) } +func _Msg_Create_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgCreate) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).Create(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/cosmos.accounts.v1.Msg/Create", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).Create(ctx, req.(*MsgCreate)) + } + return interceptor(ctx, in, info, handler) +} + var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "cosmos.accounts.v1.Msg", HandlerType: (*MsgServer)(nil), - Methods: []grpc.MethodDesc{}, - Streams: []grpc.StreamDesc{}, - Metadata: "cosmos/accounts/v1/tx.proto", + Methods: []grpc.MethodDesc{ + { + MethodName: "Create", + Handler: _Msg_Create_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "cosmos/accounts/v1/tx.proto", +} + +func (m *MsgCreate) 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 *MsgCreate) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgCreate) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Message) > 0 { + i -= len(m.Message) + copy(dAtA[i:], m.Message) + i = encodeVarintTx(dAtA, i, uint64(len(m.Message))) + i-- + dAtA[i] = 0x1a + } + if len(m.AccountType) > 0 { + i -= len(m.AccountType) + copy(dAtA[i:], m.AccountType) + i = encodeVarintTx(dAtA, i, uint64(len(m.AccountType))) + i-- + dAtA[i] = 0x12 + } + if len(m.Sender) > 0 { + i -= len(m.Sender) + copy(dAtA[i:], m.Sender) + i = encodeVarintTx(dAtA, i, uint64(len(m.Sender))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgCreateResponse) 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 *MsgCreateResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgCreateResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Response) > 0 { + i -= len(m.Response) + copy(dAtA[i:], m.Response) + i = encodeVarintTx(dAtA, i, uint64(len(m.Response))) + i-- + dAtA[i] = 0x12 + } + if len(m.AccountAddress) > 0 { + i -= len(m.AccountAddress) + copy(dAtA[i:], m.AccountAddress) + i = encodeVarintTx(dAtA, i, uint64(len(m.AccountAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintTx(dAtA []byte, offset int, v uint64) int { + offset -= sovTx(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *MsgCreate) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.AccountType) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Message) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgCreateResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.AccountAddress) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Response) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func sovTx(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 } +func sozTx(x uint64) (n int) { + return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *MsgCreate) 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 ErrIntOverflowTx + } + 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: MsgCreate: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgCreate: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Sender", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Sender = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AccountType", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AccountType = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Message", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Message = append(m.Message[:0], dAtA[iNdEx:postIndex]...) + if m.Message == nil { + m.Message = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgCreateResponse) 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 ErrIntOverflowTx + } + 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: MsgCreateResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgCreateResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AccountAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AccountAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Response", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Response = append(m.Response[:0], dAtA[iNdEx:postIndex]...) + if m.Response == nil { + m.Response = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipTx(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthTx + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupTx + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthTx + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthTx = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowTx = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupTx = fmt.Errorf("proto: unexpected end of group") +) From 4574b85d4d588013c10880b51aab059c1cd84267 Mon Sep 17 00:00:00 2001 From: unknown unknown Date: Mon, 4 Sep 2023 12:23:59 +0200 Subject: [PATCH 02/10] add msg server create2 --- .../internal/implementation/implementation_test.go | 5 ++--- x/accounts/internal/implementation/protoaccount.go | 6 +++--- x/accounts/msg_server_test.go | 10 +++++++--- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/x/accounts/internal/implementation/implementation_test.go b/x/accounts/internal/implementation/implementation_test.go index 20c3c814bd9c..350bb5342940 100644 --- a/x/accounts/internal/implementation/implementation_test.go +++ b/x/accounts/internal/implementation/implementation_test.go @@ -5,7 +5,6 @@ import ( "testing" "github.com/stretchr/testify/require" - "google.golang.org/protobuf/encoding/protojson" "google.golang.org/protobuf/proto" "google.golang.org/protobuf/reflect/protoreflect" "google.golang.org/protobuf/types/known/wrapperspb" @@ -70,7 +69,7 @@ func TestImplementation(t *testing.T) { // schemas t.Run("decode init request - ok", func(t *testing.T) { want := &wrapperspb.StringValue{Value: "test"} - req, err := protojson.Marshal(want) + req, err := proto.Marshal(want) require.NoError(t, err) got, err := impl.DecodeInitRequest(req) @@ -84,7 +83,7 @@ func TestImplementation(t *testing.T) { gotBytes, err := impl.EncodeInitResponse(want) require.NoError(t, err) - wantBytes, err := protojson.Marshal(want) + wantBytes, err := proto.Marshal(want) require.NoError(t, err) require.Equal(t, wantBytes, gotBytes) diff --git a/x/accounts/internal/implementation/protoaccount.go b/x/accounts/internal/implementation/protoaccount.go index c02dd9658945..02e2c2f15edc 100644 --- a/x/accounts/internal/implementation/protoaccount.go +++ b/x/accounts/internal/implementation/protoaccount.go @@ -4,7 +4,7 @@ import ( "context" "fmt" - "google.golang.org/protobuf/encoding/protojson" + "google.golang.org/protobuf/proto" "google.golang.org/protobuf/reflect/protoreflect" ) @@ -31,7 +31,7 @@ func RegisterInitHandler[ router.decodeRequest = func(b []byte) (any, error) { req := new(Req) - err := protojson.Unmarshal(b, ProtoReq(req)) + err := proto.Unmarshal(b, ProtoReq(req)) return req, err } @@ -40,7 +40,7 @@ func RegisterInitHandler[ if !ok { return nil, fmt.Errorf("%w: wanted %s, got %T", errInvalidMessage, respName, resp) } - return protojson.Marshal(protoResp) + return proto.Marshal(protoResp) } } diff --git a/x/accounts/msg_server_test.go b/x/accounts/msg_server_test.go index eca35b8dd6f8..875eea1e51d8 100644 --- a/x/accounts/msg_server_test.go +++ b/x/accounts/msg_server_test.go @@ -6,18 +6,19 @@ import ( "cosmossdk.io/x/accounts/internal/implementation" v1 "cosmossdk.io/x/accounts/v1" "github.com/stretchr/testify/require" - "google.golang.org/protobuf/encoding/protojson" + "google.golang.org/protobuf/proto" "google.golang.org/protobuf/types/known/emptypb" ) -func TestMsgServer_Create(t *testing.T) { +func TestMsgServer(t *testing.T) { k, ctx := newKeeper(t, map[string]implementation.Account{ "test": TestAccount{}, }) s := NewMsgServer(k) - initMsg, err := protojson.Marshal(&emptypb.Empty{}) + // create + initMsg, err := proto.Marshal(&emptypb.Empty{}) require.NoError(t, err) resp, err := s.Create(ctx, &v1.MsgCreate{ @@ -27,4 +28,7 @@ func TestMsgServer_Create(t *testing.T) { }) require.NoError(t, err) require.NotNil(t, resp) + + // execute + } From 5ea0d63b64ecac9c3b8181ab15f5e969bb42ff19 Mon Sep 17 00:00:00 2001 From: unknown unknown Date: Mon, 4 Sep 2023 12:56:23 +0200 Subject: [PATCH 03/10] add execute encoder decoder --- api/cosmos/accounts/v1/tx.pulsar.go | 1158 ++++++++++++++++- api/cosmos/accounts/v1/tx_grpc.pb.go | 41 +- proto/cosmos/accounts/v1/tx.proto | 19 + .../internal/implementation/api_builder.go | 45 +- .../internal/implementation/implementation.go | 17 +- .../implementation/implementation_test.go | 47 +- x/accounts/v1/tx.pb.go | 529 +++++++- 7 files changed, 1804 insertions(+), 52 deletions(-) diff --git a/api/cosmos/accounts/v1/tx.pulsar.go b/api/cosmos/accounts/v1/tx.pulsar.go index faa9c20146b4..cb520cdb7e17 100644 --- a/api/cosmos/accounts/v1/tx.pulsar.go +++ b/api/cosmos/accounts/v1/tx.pulsar.go @@ -1048,6 +1048,978 @@ func (x *fastReflection_MsgCreateResponse) ProtoMethods() *protoiface.Methods { } } +var ( + md_MsgExecute protoreflect.MessageDescriptor + fd_MsgExecute_sender protoreflect.FieldDescriptor + fd_MsgExecute_target protoreflect.FieldDescriptor + fd_MsgExecute_message protoreflect.FieldDescriptor +) + +func init() { + file_cosmos_accounts_v1_tx_proto_init() + md_MsgExecute = File_cosmos_accounts_v1_tx_proto.Messages().ByName("MsgExecute") + fd_MsgExecute_sender = md_MsgExecute.Fields().ByName("sender") + fd_MsgExecute_target = md_MsgExecute.Fields().ByName("target") + fd_MsgExecute_message = md_MsgExecute.Fields().ByName("message") +} + +var _ protoreflect.Message = (*fastReflection_MsgExecute)(nil) + +type fastReflection_MsgExecute MsgExecute + +func (x *MsgExecute) ProtoReflect() protoreflect.Message { + return (*fastReflection_MsgExecute)(x) +} + +func (x *MsgExecute) slowProtoReflect() protoreflect.Message { + mi := &file_cosmos_accounts_v1_tx_proto_msgTypes[2] + 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_MsgExecute_messageType fastReflection_MsgExecute_messageType +var _ protoreflect.MessageType = fastReflection_MsgExecute_messageType{} + +type fastReflection_MsgExecute_messageType struct{} + +func (x fastReflection_MsgExecute_messageType) Zero() protoreflect.Message { + return (*fastReflection_MsgExecute)(nil) +} +func (x fastReflection_MsgExecute_messageType) New() protoreflect.Message { + return new(fastReflection_MsgExecute) +} +func (x fastReflection_MsgExecute_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_MsgExecute +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_MsgExecute) Descriptor() protoreflect.MessageDescriptor { + return md_MsgExecute +} + +// 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_MsgExecute) Type() protoreflect.MessageType { + return _fastReflection_MsgExecute_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_MsgExecute) New() protoreflect.Message { + return new(fastReflection_MsgExecute) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_MsgExecute) Interface() protoreflect.ProtoMessage { + return (*MsgExecute)(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_MsgExecute) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if x.Sender != "" { + value := protoreflect.ValueOfString(x.Sender) + if !f(fd_MsgExecute_sender, value) { + return + } + } + if x.Target != "" { + value := protoreflect.ValueOfString(x.Target) + if !f(fd_MsgExecute_target, value) { + return + } + } + if len(x.Message) != 0 { + value := protoreflect.ValueOfBytes(x.Message) + if !f(fd_MsgExecute_message, 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_MsgExecute) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "cosmos.accounts.v1.MsgExecute.sender": + return x.Sender != "" + case "cosmos.accounts.v1.MsgExecute.target": + return x.Target != "" + case "cosmos.accounts.v1.MsgExecute.message": + return len(x.Message) != 0 + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.v1.MsgExecute")) + } + panic(fmt.Errorf("message cosmos.accounts.v1.MsgExecute 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_MsgExecute) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "cosmos.accounts.v1.MsgExecute.sender": + x.Sender = "" + case "cosmos.accounts.v1.MsgExecute.target": + x.Target = "" + case "cosmos.accounts.v1.MsgExecute.message": + x.Message = nil + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.v1.MsgExecute")) + } + panic(fmt.Errorf("message cosmos.accounts.v1.MsgExecute 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_MsgExecute) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "cosmos.accounts.v1.MsgExecute.sender": + value := x.Sender + return protoreflect.ValueOfString(value) + case "cosmos.accounts.v1.MsgExecute.target": + value := x.Target + return protoreflect.ValueOfString(value) + case "cosmos.accounts.v1.MsgExecute.message": + value := x.Message + return protoreflect.ValueOfBytes(value) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.v1.MsgExecute")) + } + panic(fmt.Errorf("message cosmos.accounts.v1.MsgExecute 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_MsgExecute) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "cosmos.accounts.v1.MsgExecute.sender": + x.Sender = value.Interface().(string) + case "cosmos.accounts.v1.MsgExecute.target": + x.Target = value.Interface().(string) + case "cosmos.accounts.v1.MsgExecute.message": + x.Message = value.Bytes() + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.v1.MsgExecute")) + } + panic(fmt.Errorf("message cosmos.accounts.v1.MsgExecute 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_MsgExecute) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "cosmos.accounts.v1.MsgExecute.sender": + panic(fmt.Errorf("field sender of message cosmos.accounts.v1.MsgExecute is not mutable")) + case "cosmos.accounts.v1.MsgExecute.target": + panic(fmt.Errorf("field target of message cosmos.accounts.v1.MsgExecute is not mutable")) + case "cosmos.accounts.v1.MsgExecute.message": + panic(fmt.Errorf("field message of message cosmos.accounts.v1.MsgExecute is not mutable")) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.v1.MsgExecute")) + } + panic(fmt.Errorf("message cosmos.accounts.v1.MsgExecute 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_MsgExecute) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "cosmos.accounts.v1.MsgExecute.sender": + return protoreflect.ValueOfString("") + case "cosmos.accounts.v1.MsgExecute.target": + return protoreflect.ValueOfString("") + case "cosmos.accounts.v1.MsgExecute.message": + return protoreflect.ValueOfBytes(nil) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.v1.MsgExecute")) + } + panic(fmt.Errorf("message cosmos.accounts.v1.MsgExecute 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_MsgExecute) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in cosmos.accounts.v1.MsgExecute", 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_MsgExecute) 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_MsgExecute) 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_MsgExecute) 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_MsgExecute) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*MsgExecute) + if x == nil { + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: 0, + } + } + options := runtime.SizeInputToOptions(input) + _ = options + var n int + var l int + _ = l + l = len(x.Sender) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + l = len(x.Target) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + l = len(x.Message) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + if x.unknownFields != nil { + n += len(x.unknownFields) + } + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: n, + } + } + + marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) { + x := input.Message.Interface().(*MsgExecute) + if x == nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + options := runtime.MarshalInputToOptions(input) + _ = options + size := options.Size(x) + dAtA := make([]byte, size) + i := len(dAtA) + _ = i + var l int + _ = l + if x.unknownFields != nil { + i -= len(x.unknownFields) + copy(dAtA[i:], x.unknownFields) + } + if len(x.Message) > 0 { + i -= len(x.Message) + copy(dAtA[i:], x.Message) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Message))) + i-- + dAtA[i] = 0x1a + } + if len(x.Target) > 0 { + i -= len(x.Target) + copy(dAtA[i:], x.Target) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Target))) + i-- + dAtA[i] = 0x12 + } + if len(x.Sender) > 0 { + i -= len(x.Sender) + copy(dAtA[i:], x.Sender) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Sender))) + 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().(*MsgExecute) + 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: MsgExecute: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: MsgExecute: 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 Sender", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.Sender = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Target", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.Target = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Message", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.Message = append(x.Message[:0], dAtA[iNdEx:postIndex]...) + if x.Message == nil { + x.Message = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := runtime.Skip(dAtA[iNdEx:]) + if err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if !options.DiscardUnknown { + x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + } + iNdEx += skippy + } + } + + if iNdEx > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil + } + return &protoiface.Methods{ + NoUnkeyedLiterals: struct{}{}, + Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown, + Size: size, + Marshal: marshal, + Unmarshal: unmarshal, + Merge: nil, + CheckInitialized: nil, + } +} + +var ( + md_MsgExecuteResponse protoreflect.MessageDescriptor + fd_MsgExecuteResponse_response protoreflect.FieldDescriptor +) + +func init() { + file_cosmos_accounts_v1_tx_proto_init() + md_MsgExecuteResponse = File_cosmos_accounts_v1_tx_proto.Messages().ByName("MsgExecuteResponse") + fd_MsgExecuteResponse_response = md_MsgExecuteResponse.Fields().ByName("response") +} + +var _ protoreflect.Message = (*fastReflection_MsgExecuteResponse)(nil) + +type fastReflection_MsgExecuteResponse MsgExecuteResponse + +func (x *MsgExecuteResponse) ProtoReflect() protoreflect.Message { + return (*fastReflection_MsgExecuteResponse)(x) +} + +func (x *MsgExecuteResponse) slowProtoReflect() protoreflect.Message { + mi := &file_cosmos_accounts_v1_tx_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +var _fastReflection_MsgExecuteResponse_messageType fastReflection_MsgExecuteResponse_messageType +var _ protoreflect.MessageType = fastReflection_MsgExecuteResponse_messageType{} + +type fastReflection_MsgExecuteResponse_messageType struct{} + +func (x fastReflection_MsgExecuteResponse_messageType) Zero() protoreflect.Message { + return (*fastReflection_MsgExecuteResponse)(nil) +} +func (x fastReflection_MsgExecuteResponse_messageType) New() protoreflect.Message { + return new(fastReflection_MsgExecuteResponse) +} +func (x fastReflection_MsgExecuteResponse_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_MsgExecuteResponse +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_MsgExecuteResponse) Descriptor() protoreflect.MessageDescriptor { + return md_MsgExecuteResponse +} + +// 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_MsgExecuteResponse) Type() protoreflect.MessageType { + return _fastReflection_MsgExecuteResponse_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_MsgExecuteResponse) New() protoreflect.Message { + return new(fastReflection_MsgExecuteResponse) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_MsgExecuteResponse) Interface() protoreflect.ProtoMessage { + return (*MsgExecuteResponse)(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_MsgExecuteResponse) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if len(x.Response) != 0 { + value := protoreflect.ValueOfBytes(x.Response) + if !f(fd_MsgExecuteResponse_response, 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_MsgExecuteResponse) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "cosmos.accounts.v1.MsgExecuteResponse.response": + return len(x.Response) != 0 + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.v1.MsgExecuteResponse")) + } + panic(fmt.Errorf("message cosmos.accounts.v1.MsgExecuteResponse 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_MsgExecuteResponse) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "cosmos.accounts.v1.MsgExecuteResponse.response": + x.Response = nil + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.v1.MsgExecuteResponse")) + } + panic(fmt.Errorf("message cosmos.accounts.v1.MsgExecuteResponse 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_MsgExecuteResponse) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "cosmos.accounts.v1.MsgExecuteResponse.response": + value := x.Response + return protoreflect.ValueOfBytes(value) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.v1.MsgExecuteResponse")) + } + panic(fmt.Errorf("message cosmos.accounts.v1.MsgExecuteResponse 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_MsgExecuteResponse) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "cosmos.accounts.v1.MsgExecuteResponse.response": + x.Response = value.Bytes() + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.v1.MsgExecuteResponse")) + } + panic(fmt.Errorf("message cosmos.accounts.v1.MsgExecuteResponse 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_MsgExecuteResponse) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "cosmos.accounts.v1.MsgExecuteResponse.response": + panic(fmt.Errorf("field response of message cosmos.accounts.v1.MsgExecuteResponse is not mutable")) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.v1.MsgExecuteResponse")) + } + panic(fmt.Errorf("message cosmos.accounts.v1.MsgExecuteResponse 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_MsgExecuteResponse) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "cosmos.accounts.v1.MsgExecuteResponse.response": + return protoreflect.ValueOfBytes(nil) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.v1.MsgExecuteResponse")) + } + panic(fmt.Errorf("message cosmos.accounts.v1.MsgExecuteResponse 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_MsgExecuteResponse) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in cosmos.accounts.v1.MsgExecuteResponse", 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_MsgExecuteResponse) 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_MsgExecuteResponse) 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_MsgExecuteResponse) 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_MsgExecuteResponse) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*MsgExecuteResponse) + if x == nil { + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: 0, + } + } + options := runtime.SizeInputToOptions(input) + _ = options + var n int + var l int + _ = l + l = len(x.Response) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + if x.unknownFields != nil { + n += len(x.unknownFields) + } + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: n, + } + } + + marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) { + x := input.Message.Interface().(*MsgExecuteResponse) + if x == nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + options := runtime.MarshalInputToOptions(input) + _ = options + size := options.Size(x) + dAtA := make([]byte, size) + i := len(dAtA) + _ = i + var l int + _ = l + if x.unknownFields != nil { + i -= len(x.unknownFields) + copy(dAtA[i:], x.unknownFields) + } + if len(x.Response) > 0 { + i -= len(x.Response) + copy(dAtA[i:], x.Response) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Response))) + 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().(*MsgExecuteResponse) + 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: MsgExecuteResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: MsgExecuteResponse: 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 Response", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.Response = append(x.Response[:0], dAtA[iNdEx:postIndex]...) + if x.Response == nil { + x.Response = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := runtime.Skip(dAtA[iNdEx:]) + if err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if !options.DiscardUnknown { + x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + } + iNdEx += skippy + } + } + + if iNdEx > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil + } + return &protoiface.Methods{ + NoUnkeyedLiterals: struct{}{}, + Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown, + Size: size, + Marshal: marshal, + Unmarshal: unmarshal, + Merge: nil, + CheckInitialized: nil, + } +} + // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.27.0 @@ -1164,6 +2136,98 @@ func (x *MsgCreateResponse) GetResponse() []byte { return nil } +// MsgExecute defines the Execute request type for the Msg/Execute RPC method. +type MsgExecute struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // sender is the address of the sender of this message. + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` + // target is the address of the account to be executed. + Target string `protobuf:"bytes,2,opt,name=target,proto3" json:"target,omitempty"` + // message is the message to be sent to the account, it's up to the account + Message []byte `protobuf:"bytes,3,opt,name=message,proto3" json:"message,omitempty"` +} + +func (x *MsgExecute) Reset() { + *x = MsgExecute{} + if protoimpl.UnsafeEnabled { + mi := &file_cosmos_accounts_v1_tx_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *MsgExecute) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*MsgExecute) ProtoMessage() {} + +// Deprecated: Use MsgExecute.ProtoReflect.Descriptor instead. +func (*MsgExecute) Descriptor() ([]byte, []int) { + return file_cosmos_accounts_v1_tx_proto_rawDescGZIP(), []int{2} +} + +func (x *MsgExecute) GetSender() string { + if x != nil { + return x.Sender + } + return "" +} + +func (x *MsgExecute) GetTarget() string { + if x != nil { + return x.Target + } + return "" +} + +func (x *MsgExecute) GetMessage() []byte { + if x != nil { + return x.Message + } + return nil +} + +// MsgExecuteResponse defines the Execute response type for the Msg/Execute RPC method. +type MsgExecuteResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // response is the response returned by the account implementation. + Response []byte `protobuf:"bytes,1,opt,name=response,proto3" json:"response,omitempty"` +} + +func (x *MsgExecuteResponse) Reset() { + *x = MsgExecuteResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_cosmos_accounts_v1_tx_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *MsgExecuteResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*MsgExecuteResponse) ProtoMessage() {} + +// Deprecated: Use MsgExecuteResponse.ProtoReflect.Descriptor instead. +func (*MsgExecuteResponse) Descriptor() ([]byte, []int) { + return file_cosmos_accounts_v1_tx_proto_rawDescGZIP(), []int{3} +} + +func (x *MsgExecuteResponse) GetResponse() []byte { + if x != nil { + return x.Response + } + return nil +} + var File_cosmos_accounts_v1_tx_proto protoreflect.FileDescriptor var file_cosmos_accounts_v1_tx_proto_rawDesc = []byte{ @@ -1181,25 +2245,39 @@ var file_cosmos_accounts_v1_tx_proto_rawDesc = []byte{ 0x75, 0x6e, 0x74, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x0c, 0x52, 0x08, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0x55, 0x0a, - 0x03, 0x4d, 0x73, 0x67, 0x12, 0x4e, 0x0a, 0x06, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x12, 0x1d, - 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, - 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x1a, 0x25, 0x2e, - 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2e, - 0x76, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x42, 0xbb, 0x01, 0x0a, 0x16, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, - 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2e, 0x76, 0x31, 0x42, - 0x07, 0x54, 0x78, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x2e, 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, 0x76, 0x31, 0x3b, - 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x41, 0x58, - 0xaa, 0x02, 0x12, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, - 0x74, 0x73, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x12, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x41, - 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x1e, 0x43, 0x6f, 0x73, - 0x6d, 0x6f, 0x73, 0x5c, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x5c, 0x56, 0x31, 0x5c, - 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x14, 0x43, 0x6f, - 0x73, 0x6d, 0x6f, 0x73, 0x3a, 0x3a, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x3a, 0x3a, - 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x01, 0x28, 0x0c, 0x52, 0x08, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x56, 0x0a, + 0x0a, 0x4d, 0x73, 0x67, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x73, + 0x65, 0x6e, 0x64, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x65, 0x6e, + 0x64, 0x65, 0x72, 0x12, 0x16, 0x0a, 0x06, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x06, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x6d, + 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x6d, 0x65, + 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x30, 0x0a, 0x12, 0x4d, 0x73, 0x67, 0x45, 0x78, 0x65, 0x63, + 0x75, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x72, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x08, 0x72, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0xa8, 0x01, 0x0a, 0x03, 0x4d, 0x73, 0x67, 0x12, + 0x4e, 0x0a, 0x06, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x12, 0x1d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, + 0x6f, 0x73, 0x2e, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x4d, + 0x73, 0x67, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x1a, 0x25, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, + 0x73, 0x2e, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x73, + 0x67, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, + 0x51, 0x0a, 0x07, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x65, 0x12, 0x1e, 0x2e, 0x63, 0x6f, 0x73, + 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2e, 0x76, 0x31, 0x2e, + 0x4d, 0x73, 0x67, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x65, 0x1a, 0x26, 0x2e, 0x63, 0x6f, 0x73, + 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2e, 0x76, 0x31, 0x2e, + 0x4d, 0x73, 0x67, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x42, 0xbb, 0x01, 0x0a, 0x16, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, + 0x73, 0x2e, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2e, 0x76, 0x31, 0x42, 0x07, 0x54, + 0x78, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x2e, 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, 0x76, 0x31, 0x3b, 0x61, 0x63, + 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x41, 0x58, 0xaa, 0x02, + 0x12, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, + 0x2e, 0x56, 0x31, 0xca, 0x02, 0x12, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x41, 0x63, 0x63, + 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x1e, 0x43, 0x6f, 0x73, 0x6d, 0x6f, + 0x73, 0x5c, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, + 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x14, 0x43, 0x6f, 0x73, 0x6d, + 0x6f, 0x73, 0x3a, 0x3a, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x3a, 0x3a, 0x56, 0x31, + 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -1214,16 +2292,20 @@ func file_cosmos_accounts_v1_tx_proto_rawDescGZIP() []byte { return file_cosmos_accounts_v1_tx_proto_rawDescData } -var file_cosmos_accounts_v1_tx_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_cosmos_accounts_v1_tx_proto_msgTypes = make([]protoimpl.MessageInfo, 4) var file_cosmos_accounts_v1_tx_proto_goTypes = []interface{}{ - (*MsgCreate)(nil), // 0: cosmos.accounts.v1.MsgCreate - (*MsgCreateResponse)(nil), // 1: cosmos.accounts.v1.MsgCreateResponse + (*MsgCreate)(nil), // 0: cosmos.accounts.v1.MsgCreate + (*MsgCreateResponse)(nil), // 1: cosmos.accounts.v1.MsgCreateResponse + (*MsgExecute)(nil), // 2: cosmos.accounts.v1.MsgExecute + (*MsgExecuteResponse)(nil), // 3: cosmos.accounts.v1.MsgExecuteResponse } var file_cosmos_accounts_v1_tx_proto_depIdxs = []int32{ 0, // 0: cosmos.accounts.v1.Msg.Create:input_type -> cosmos.accounts.v1.MsgCreate - 1, // 1: cosmos.accounts.v1.Msg.Create:output_type -> cosmos.accounts.v1.MsgCreateResponse - 1, // [1:2] is the sub-list for method output_type - 0, // [0:1] is the sub-list for method input_type + 2, // 1: cosmos.accounts.v1.Msg.Execute:input_type -> cosmos.accounts.v1.MsgExecute + 1, // 2: cosmos.accounts.v1.Msg.Create:output_type -> cosmos.accounts.v1.MsgCreateResponse + 3, // 3: cosmos.accounts.v1.Msg.Execute:output_type -> cosmos.accounts.v1.MsgExecuteResponse + 2, // [2:4] is the sub-list for method output_type + 0, // [0:2] 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 @@ -1259,6 +2341,30 @@ func file_cosmos_accounts_v1_tx_proto_init() { return nil } } + file_cosmos_accounts_v1_tx_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*MsgExecute); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_cosmos_accounts_v1_tx_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*MsgExecuteResponse); 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{ @@ -1266,7 +2372,7 @@ func file_cosmos_accounts_v1_tx_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_cosmos_accounts_v1_tx_proto_rawDesc, NumEnums: 0, - NumMessages: 2, + NumMessages: 4, NumExtensions: 0, NumServices: 1, }, diff --git a/api/cosmos/accounts/v1/tx_grpc.pb.go b/api/cosmos/accounts/v1/tx_grpc.pb.go index fb5722bc8e7b..ccf2410ed165 100644 --- a/api/cosmos/accounts/v1/tx_grpc.pb.go +++ b/api/cosmos/accounts/v1/tx_grpc.pb.go @@ -19,7 +19,8 @@ import ( const _ = grpc.SupportPackageIsVersion7 const ( - Msg_Create_FullMethodName = "/cosmos.accounts.v1.Msg/Create" + Msg_Create_FullMethodName = "/cosmos.accounts.v1.Msg/Create" + Msg_Execute_FullMethodName = "/cosmos.accounts.v1.Msg/Execute" ) // MsgClient is the client API for Msg service. @@ -28,6 +29,8 @@ const ( type MsgClient interface { // Create creates a new account in the chain. Create(ctx context.Context, in *MsgCreate, opts ...grpc.CallOption) (*MsgCreateResponse, error) + // Execute executes a message to the target account. + Execute(ctx context.Context, in *MsgExecute, opts ...grpc.CallOption) (*MsgExecuteResponse, error) } type msgClient struct { @@ -47,12 +50,23 @@ func (c *msgClient) Create(ctx context.Context, in *MsgCreate, opts ...grpc.Call return out, nil } +func (c *msgClient) Execute(ctx context.Context, in *MsgExecute, opts ...grpc.CallOption) (*MsgExecuteResponse, error) { + out := new(MsgExecuteResponse) + err := c.cc.Invoke(ctx, Msg_Execute_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // MsgServer is the server API for Msg service. // All implementations must embed UnimplementedMsgServer // for forward compatibility type MsgServer interface { // Create creates a new account in the chain. Create(context.Context, *MsgCreate) (*MsgCreateResponse, error) + // Execute executes a message to the target account. + Execute(context.Context, *MsgExecute) (*MsgExecuteResponse, error) mustEmbedUnimplementedMsgServer() } @@ -63,6 +77,9 @@ type UnimplementedMsgServer struct { func (UnimplementedMsgServer) Create(context.Context, *MsgCreate) (*MsgCreateResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Create not implemented") } +func (UnimplementedMsgServer) Execute(context.Context, *MsgExecute) (*MsgExecuteResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Execute not implemented") +} func (UnimplementedMsgServer) mustEmbedUnimplementedMsgServer() {} // UnsafeMsgServer may be embedded to opt out of forward compatibility for this service. @@ -94,6 +111,24 @@ func _Msg_Create_Handler(srv interface{}, ctx context.Context, dec func(interfac return interceptor(ctx, in, info, handler) } +func _Msg_Execute_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgExecute) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).Execute(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Msg_Execute_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).Execute(ctx, req.(*MsgExecute)) + } + return interceptor(ctx, in, info, handler) +} + // Msg_ServiceDesc is the grpc.ServiceDesc for Msg service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -105,6 +140,10 @@ var Msg_ServiceDesc = grpc.ServiceDesc{ MethodName: "Create", Handler: _Msg_Create_Handler, }, + { + MethodName: "Execute", + Handler: _Msg_Execute_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "cosmos/accounts/v1/tx.proto", diff --git a/proto/cosmos/accounts/v1/tx.proto b/proto/cosmos/accounts/v1/tx.proto index a03a22179544..28bce1da89e6 100644 --- a/proto/cosmos/accounts/v1/tx.proto +++ b/proto/cosmos/accounts/v1/tx.proto @@ -8,6 +8,9 @@ option go_package = "cosmossdk.io/x/accounts/v1"; service Msg { // Create creates a new account in the chain. rpc Create(MsgCreate) returns (MsgCreateResponse); + + // Execute executes a message to the target account. + rpc Execute(MsgExecute) returns (MsgExecuteResponse); } // MsgCreate defines the Create request type for the Msg/Create RPC method. @@ -29,3 +32,19 @@ message MsgCreateResponse { // response is the response returned by the account implementation. bytes response = 2; } + +// MsgExecute defines the Execute request type for the Msg/Execute RPC method. +message MsgExecute { + // sender is the address of the sender of this message. + string sender = 1; + // target is the address of the account to be executed. + string target = 2; + // message is the message to be sent to the account, it's up to the account + bytes message = 3; +} + +// MsgExecuteResponse defines the Execute response type for the Msg/Execute RPC method. +message MsgExecuteResponse { + // response is the response returned by the account implementation. + bytes response = 1; +} diff --git a/x/accounts/internal/implementation/api_builder.go b/x/accounts/internal/implementation/api_builder.go index de887373a54f..3fae0c5e93df 100644 --- a/x/accounts/internal/implementation/api_builder.go +++ b/x/accounts/internal/implementation/api_builder.go @@ -5,7 +5,9 @@ import ( "errors" "fmt" + "google.golang.org/protobuf/proto" "google.golang.org/protobuf/reflect/protoreflect" + "google.golang.org/protobuf/types/known/anypb" ) var ( @@ -54,7 +56,6 @@ func NewExecuteBuilder() *ExecuteBuilder { type ExecuteBuilder struct { // handlers is a map of handler functions that will be called when the smart account is executed. handlers map[string]func(ctx context.Context, executeRequest any) (executeResponse any, err error) - // err is the error that occurred before building the handler function. err error } @@ -93,6 +94,48 @@ func (r *ExecuteBuilder) makeHandler() (func(ctx context.Context, executeRequest }, nil } +func (r *ExecuteBuilder) makeRequestDecoder() func(requestBytes []byte) (any, error) { + return func(requestBytes []byte) (any, error) { + anyPB := new(anypb.Any) + err := proto.Unmarshal(requestBytes, anyPB) + if err != nil { + return nil, err + } + + msg, err := anyPB.UnmarshalNew() + if err != nil { + return nil, err + } + + // check if part of the msg set + if _, exists := r.handlers[string(msg.ProtoReflect().Descriptor().FullName())]; !exists { + return nil, fmt.Errorf("%w: no handler for message %s", errInvalidMessage, string(msg.ProtoReflect().Descriptor().FullName())) + } + + return msg, nil + } +} + +func (r *ExecuteBuilder) makeResponseEncoder() func(executeResponse any) ([]byte, error) { + return func(executeResponse any) ([]byte, error) { + executeResponsePB, ok := executeResponse.(protoreflect.ProtoMessage) + if !ok { + return nil, fmt.Errorf("%w: expected protoreflect.Message, got %T", errInvalidMessage, executeResponse) + } + + // check if part of the msg set + if _, exists := r.handlers[string(executeResponsePB.ProtoReflect().Descriptor().FullName())]; !exists { + return nil, fmt.Errorf("%w: not part of message set %s", errInvalidMessage, string(executeResponsePB.ProtoReflect().Descriptor().FullName())) + } + anyPB, err := anypb.New(executeResponsePB) + if err != nil { + return nil, err + } + + return proto.Marshal(anyPB) + } +} + // NewQueryBuilder creates a new QueryBuilder instance. func NewQueryBuilder() *QueryBuilder { return &QueryBuilder{ diff --git a/x/accounts/internal/implementation/implementation.go b/x/accounts/internal/implementation/implementation.go index 4ec274f9487c..4a517da69163 100644 --- a/x/accounts/internal/implementation/implementation.go +++ b/x/accounts/internal/implementation/implementation.go @@ -28,11 +28,13 @@ func NewImplementation(account Account) (Implementation, error) { return Implementation{}, err } return Implementation{ - Init: initHandler, - Execute: executeHandler, - Query: queryHandler, - DecodeInitRequest: ir.decodeRequest, - EncodeInitResponse: ir.encodeResponse, + Init: initHandler, + Execute: executeHandler, + Query: queryHandler, + DecodeInitRequest: ir.decodeRequest, + EncodeInitResponse: ir.encodeResponse, + DecodeExecuteRequest: er.makeRequestDecoder(), + EncodeExecuteResponse: er.makeResponseEncoder(), }, nil } @@ -52,4 +54,9 @@ type Implementation struct { DecodeInitRequest func([]byte) (any, error) // EncodeInitResponse encodes an init response to be sent back from the message server. EncodeInitResponse func(any) ([]byte, error) + + // DecodeExecuteRequest decodes an execute request coming from the message server. + DecodeExecuteRequest func([]byte) (any, error) + // EncodeExecuteResponse encodes an execute response to be sent back from the message server. + EncodeExecuteResponse func(any) ([]byte, error) } diff --git a/x/accounts/internal/implementation/implementation_test.go b/x/accounts/internal/implementation/implementation_test.go index 350bb5342940..ca98e526b9d6 100644 --- a/x/accounts/internal/implementation/implementation_test.go +++ b/x/accounts/internal/implementation/implementation_test.go @@ -7,6 +7,7 @@ import ( "github.com/stretchr/testify/require" "google.golang.org/protobuf/proto" "google.golang.org/protobuf/reflect/protoreflect" + "google.golang.org/protobuf/types/known/anypb" "google.golang.org/protobuf/types/known/wrapperspb" ) @@ -89,8 +90,52 @@ func TestImplementation(t *testing.T) { require.Equal(t, wantBytes, gotBytes) }) - t.Run("decode init response - invalid message", func(t *testing.T) { + t.Run("encode init response - invalid message", func(t *testing.T) { _, err := impl.EncodeInitResponse([]byte("invalid")) require.ErrorIs(t, err, errInvalidMessage) }) + + t.Run("decode execute request - ok", func(t *testing.T) { + wantReq := &wrapperspb.StringValue{Value: "test"} + anyBPReq, err := anypb.New(wantReq) + require.NoError(t, err) + reqBytes, err := proto.Marshal(anyBPReq) + require.NoError(t, err) + gotReq, err := impl.DecodeExecuteRequest(reqBytes) + require.NoError(t, err) + require.True(t, proto.Equal(wantReq, gotReq.(protoreflect.ProtoMessage))) + }) + + t.Run("decode execute request - invalid message", func(t *testing.T) { + req := wrapperspb.Double(1) + anyPBReq, err := anypb.New(req) + require.NoError(t, err) + reqBytes, err := proto.Marshal(anyPBReq) + require.NoError(t, err) + _, err = impl.DecodeExecuteRequest(reqBytes) + require.ErrorIs(t, err, errInvalidMessage) + }) + + t.Run("encode execute response - ok", func(t *testing.T) { + resp := &wrapperspb.StringValue{Value: "test"} + gotRespBytes, err := impl.EncodeExecuteResponse(resp) + require.NoError(t, err) + anyPBResp, err := anypb.New(resp) + require.NoError(t, err) + wantRespBytes, err := proto.Marshal(anyPBResp) + require.NoError(t, err) + require.Equal(t, wantRespBytes, gotRespBytes) + }) + + t.Run("encode execute response - not a protobuf message", func(t *testing.T) { + _, err := impl.EncodeExecuteResponse("test") + require.ErrorIs(t, err, errInvalidMessage) + require.ErrorContains(t, err, "expected protoreflect.Message") + }) + + t.Run("encode execute response - not part of the message set", func(t *testing.T) { + _, err := impl.EncodeExecuteResponse(&wrapperspb.DoubleValue{Value: 1}) + require.ErrorIs(t, err, errInvalidMessage) + require.ErrorContains(t, err, "not part of message set") + }) } diff --git a/x/accounts/v1/tx.pb.go b/x/accounts/v1/tx.pb.go index 961d81a81613..e0402635b22f 100644 --- a/x/accounts/v1/tx.pb.go +++ b/x/accounts/v1/tx.pb.go @@ -148,32 +148,147 @@ func (m *MsgCreateResponse) GetResponse() []byte { return nil } +// MsgExecute defines the Execute request type for the Msg/Execute RPC method. +type MsgExecute struct { + // sender is the address of the sender of this message. + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` + // target is the address of the account to be executed. + Target string `protobuf:"bytes,2,opt,name=target,proto3" json:"target,omitempty"` + // message is the message to be sent to the account, it's up to the account + Message []byte `protobuf:"bytes,3,opt,name=message,proto3" json:"message,omitempty"` +} + +func (m *MsgExecute) Reset() { *m = MsgExecute{} } +func (m *MsgExecute) String() string { return proto.CompactTextString(m) } +func (*MsgExecute) ProtoMessage() {} +func (*MsgExecute) Descriptor() ([]byte, []int) { + return fileDescriptor_29c2b6d8a13d4189, []int{2} +} +func (m *MsgExecute) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgExecute) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgExecute.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 *MsgExecute) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgExecute.Merge(m, src) +} +func (m *MsgExecute) XXX_Size() int { + return m.Size() +} +func (m *MsgExecute) XXX_DiscardUnknown() { + xxx_messageInfo_MsgExecute.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgExecute proto.InternalMessageInfo + +func (m *MsgExecute) GetSender() string { + if m != nil { + return m.Sender + } + return "" +} + +func (m *MsgExecute) GetTarget() string { + if m != nil { + return m.Target + } + return "" +} + +func (m *MsgExecute) GetMessage() []byte { + if m != nil { + return m.Message + } + return nil +} + +// MsgExecuteResponse defines the Execute response type for the Msg/Execute RPC method. +type MsgExecuteResponse struct { + // response is the response returned by the account implementation. + Response []byte `protobuf:"bytes,1,opt,name=response,proto3" json:"response,omitempty"` +} + +func (m *MsgExecuteResponse) Reset() { *m = MsgExecuteResponse{} } +func (m *MsgExecuteResponse) String() string { return proto.CompactTextString(m) } +func (*MsgExecuteResponse) ProtoMessage() {} +func (*MsgExecuteResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_29c2b6d8a13d4189, []int{3} +} +func (m *MsgExecuteResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgExecuteResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgExecuteResponse.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 *MsgExecuteResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgExecuteResponse.Merge(m, src) +} +func (m *MsgExecuteResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgExecuteResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgExecuteResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgExecuteResponse proto.InternalMessageInfo + +func (m *MsgExecuteResponse) GetResponse() []byte { + if m != nil { + return m.Response + } + return nil +} + func init() { proto.RegisterType((*MsgCreate)(nil), "cosmos.accounts.v1.MsgCreate") proto.RegisterType((*MsgCreateResponse)(nil), "cosmos.accounts.v1.MsgCreateResponse") + proto.RegisterType((*MsgExecute)(nil), "cosmos.accounts.v1.MsgExecute") + proto.RegisterType((*MsgExecuteResponse)(nil), "cosmos.accounts.v1.MsgExecuteResponse") } func init() { proto.RegisterFile("cosmos/accounts/v1/tx.proto", fileDescriptor_29c2b6d8a13d4189) } var fileDescriptor_29c2b6d8a13d4189 = []byte{ - // 259 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4e, 0xce, 0x2f, 0xce, - 0xcd, 0x2f, 0xd6, 0x4f, 0x4c, 0x4e, 0xce, 0x2f, 0xcd, 0x2b, 0x29, 0xd6, 0x2f, 0x33, 0xd4, 0x2f, - 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x82, 0x48, 0xea, 0xc1, 0x24, 0xf5, 0xca, - 0x0c, 0x95, 0x12, 0xb8, 0x38, 0x7d, 0x8b, 0xd3, 0x9d, 0x8b, 0x52, 0x13, 0x4b, 0x52, 0x85, 0xc4, - 0xb8, 0xd8, 0x8a, 0x53, 0xf3, 0x52, 0x52, 0x8b, 0x24, 0x18, 0x15, 0x18, 0x35, 0x38, 0x83, 0xa0, - 0x3c, 0x21, 0x45, 0x2e, 0x1e, 0xa8, 0x9e, 0xf8, 0x92, 0xca, 0x82, 0x54, 0x09, 0x26, 0xb0, 0x2c, - 0x37, 0x54, 0x2c, 0xa4, 0xb2, 0x20, 0x55, 0x48, 0x82, 0x8b, 0x3d, 0x37, 0xb5, 0xb8, 0x38, 0x31, - 0x3d, 0x55, 0x82, 0x59, 0x81, 0x51, 0x83, 0x27, 0x08, 0xc6, 0x55, 0x8a, 0xe0, 0x12, 0x84, 0xdb, - 0x10, 0x94, 0x5a, 0x5c, 0x90, 0x9f, 0x57, 0x9c, 0x2a, 0xa4, 0xce, 0xc5, 0x0f, 0x33, 0x31, 0x31, - 0x25, 0xa5, 0x28, 0xb5, 0xb8, 0x18, 0x6a, 0x25, 0x1f, 0x54, 0xd8, 0x11, 0x22, 0x2a, 0x24, 0xc5, - 0xc5, 0x51, 0x04, 0xd5, 0x04, 0xb6, 0x96, 0x27, 0x08, 0xce, 0x37, 0x0a, 0xe5, 0x62, 0xf6, 0x2d, - 0x4e, 0x17, 0xf2, 0xe3, 0x62, 0x83, 0xba, 0x5f, 0x56, 0x0f, 0xd3, 0x87, 0x7a, 0x70, 0xcb, 0xa5, - 0x54, 0xf1, 0x4a, 0xc3, 0xdc, 0xe6, 0x64, 0x72, 0xe2, 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, - 0x0f, 0x1e, 0xc9, 0x31, 0x4e, 0x78, 0x2c, 0xc7, 0x70, 0xe1, 0xb1, 0x1c, 0xc3, 0x8d, 0xc7, 0x72, - 0x0c, 0x51, 0x52, 0x10, 0xfd, 0xc5, 0x29, 0xd9, 0x7a, 0x99, 0xf9, 0xfa, 0x15, 0xc8, 0xa1, 0x9c, - 0xc4, 0x06, 0x0e, 0x63, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0x42, 0x72, 0x84, 0xc2, 0x82, - 0x01, 0x00, 0x00, + // 316 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x92, 0xc1, 0x4a, 0xf3, 0x40, + 0x14, 0x85, 0x3b, 0x7f, 0x21, 0xfd, 0x7b, 0x2d, 0x8a, 0xb3, 0x28, 0x21, 0xe2, 0x50, 0x0b, 0x6a, + 0x57, 0x13, 0xab, 0xbe, 0x80, 0x8a, 0xcb, 0x0a, 0x06, 0x11, 0x71, 0xa3, 0x31, 0xb9, 0x04, 0x91, + 0x76, 0xc2, 0xdc, 0x69, 0x69, 0xdf, 0xc2, 0xc7, 0xf0, 0x51, 0x5c, 0x76, 0xe9, 0x52, 0x9a, 0x17, + 0x11, 0x92, 0x49, 0xac, 0x88, 0x59, 0x9e, 0x7b, 0xb8, 0xe7, 0x7c, 0x73, 0x19, 0xd8, 0x89, 0x14, + 0x8d, 0x15, 0xf9, 0x61, 0x14, 0xa9, 0xe9, 0xc4, 0x90, 0x3f, 0x1b, 0xfa, 0x66, 0x2e, 0x53, 0xad, + 0x8c, 0xe2, 0xbc, 0x30, 0x65, 0x69, 0xca, 0xd9, 0xb0, 0xff, 0x08, 0xed, 0x11, 0x25, 0x17, 0x1a, + 0x43, 0x83, 0xbc, 0x0b, 0x0e, 0xe1, 0x24, 0x46, 0xed, 0xb2, 0x1e, 0x1b, 0xb4, 0x03, 0xab, 0xf8, + 0x1e, 0x74, 0xec, 0xce, 0x83, 0x59, 0xa4, 0xe8, 0xfe, 0xcb, 0xdd, 0x0d, 0x3b, 0xbb, 0x59, 0xa4, + 0xc8, 0x5d, 0x68, 0x8d, 0x91, 0x28, 0x4c, 0xd0, 0x6d, 0xf6, 0xd8, 0xa0, 0x13, 0x94, 0xb2, 0x7f, + 0x07, 0xdb, 0x55, 0x43, 0x80, 0x94, 0xaa, 0x09, 0x21, 0x3f, 0x84, 0xad, 0x32, 0x31, 0x8c, 0x63, + 0x8d, 0x44, 0xb6, 0x72, 0xd3, 0x8e, 0xcf, 0x8a, 0x29, 0xf7, 0xe0, 0xbf, 0xb6, 0x4b, 0x79, 0x6d, + 0x27, 0xa8, 0x74, 0xff, 0x16, 0x60, 0x44, 0xc9, 0xe5, 0x1c, 0xa3, 0x69, 0x0d, 0x7c, 0x17, 0x1c, + 0x13, 0xea, 0x04, 0x8d, 0xc5, 0xb6, 0xaa, 0x86, 0xf8, 0x08, 0xf8, 0x77, 0x6e, 0x85, 0xbc, 0x4e, + 0xc2, 0x7e, 0x92, 0x1c, 0xbf, 0x31, 0x68, 0x8e, 0x28, 0xe1, 0x57, 0xe0, 0xd8, 0x53, 0xee, 0xca, + 0xdf, 0xc7, 0x96, 0xd5, 0x1d, 0xbc, 0xfd, 0x5a, 0xbb, 0xea, 0xbc, 0x86, 0x56, 0xf9, 0x3c, 0xf1, + 0xc7, 0x86, 0xf5, 0xbd, 0x83, 0x7a, 0xbf, 0x8c, 0x3c, 0x3f, 0x7d, 0x5f, 0x09, 0xb6, 0x5c, 0x09, + 0xf6, 0xb9, 0x12, 0xec, 0x35, 0x13, 0x8d, 0x65, 0x26, 0x1a, 0x1f, 0x99, 0x68, 0xdc, 0x7b, 0x45, + 0x00, 0xc5, 0x2f, 0xf2, 0x59, 0xf9, 0xf3, 0xf5, 0x3f, 0xf4, 0xe4, 0xe4, 0x3f, 0xe8, 0xe4, 0x2b, + 0x00, 0x00, 0xff, 0xff, 0x51, 0x1c, 0xbf, 0x06, 0x60, 0x02, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -190,6 +305,8 @@ const _ = grpc.SupportPackageIsVersion4 type MsgClient interface { // Create creates a new account in the chain. Create(ctx context.Context, in *MsgCreate, opts ...grpc.CallOption) (*MsgCreateResponse, error) + // Execute executes a message to the target account. + Execute(ctx context.Context, in *MsgExecute, opts ...grpc.CallOption) (*MsgExecuteResponse, error) } type msgClient struct { @@ -209,10 +326,21 @@ func (c *msgClient) Create(ctx context.Context, in *MsgCreate, opts ...grpc.Call return out, nil } +func (c *msgClient) Execute(ctx context.Context, in *MsgExecute, opts ...grpc.CallOption) (*MsgExecuteResponse, error) { + out := new(MsgExecuteResponse) + err := c.cc.Invoke(ctx, "/cosmos.accounts.v1.Msg/Execute", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // MsgServer is the server API for Msg service. type MsgServer interface { // Create creates a new account in the chain. Create(context.Context, *MsgCreate) (*MsgCreateResponse, error) + // Execute executes a message to the target account. + Execute(context.Context, *MsgExecute) (*MsgExecuteResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. @@ -222,6 +350,9 @@ type UnimplementedMsgServer struct { func (*UnimplementedMsgServer) Create(ctx context.Context, req *MsgCreate) (*MsgCreateResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Create not implemented") } +func (*UnimplementedMsgServer) Execute(ctx context.Context, req *MsgExecute) (*MsgExecuteResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Execute not implemented") +} func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) @@ -245,6 +376,24 @@ func _Msg_Create_Handler(srv interface{}, ctx context.Context, dec func(interfac return interceptor(ctx, in, info, handler) } +func _Msg_Execute_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgExecute) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).Execute(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/cosmos.accounts.v1.Msg/Execute", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).Execute(ctx, req.(*MsgExecute)) + } + return interceptor(ctx, in, info, handler) +} + var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "cosmos.accounts.v1.Msg", HandlerType: (*MsgServer)(nil), @@ -253,6 +402,10 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "Create", Handler: _Msg_Create_Handler, }, + { + MethodName: "Execute", + Handler: _Msg_Execute_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "cosmos/accounts/v1/tx.proto", @@ -339,6 +492,80 @@ func (m *MsgCreateResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *MsgExecute) 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 *MsgExecute) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgExecute) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Message) > 0 { + i -= len(m.Message) + copy(dAtA[i:], m.Message) + i = encodeVarintTx(dAtA, i, uint64(len(m.Message))) + i-- + dAtA[i] = 0x1a + } + if len(m.Target) > 0 { + i -= len(m.Target) + copy(dAtA[i:], m.Target) + i = encodeVarintTx(dAtA, i, uint64(len(m.Target))) + i-- + dAtA[i] = 0x12 + } + if len(m.Sender) > 0 { + i -= len(m.Sender) + copy(dAtA[i:], m.Sender) + i = encodeVarintTx(dAtA, i, uint64(len(m.Sender))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgExecuteResponse) 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 *MsgExecuteResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgExecuteResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Response) > 0 { + i -= len(m.Response) + copy(dAtA[i:], m.Response) + i = encodeVarintTx(dAtA, i, uint64(len(m.Response))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func encodeVarintTx(dAtA []byte, offset int, v uint64) int { offset -= sovTx(v) base := offset @@ -388,6 +615,40 @@ func (m *MsgCreateResponse) Size() (n int) { return n } +func (m *MsgExecute) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Target) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Message) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgExecuteResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Response) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + func sovTx(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -658,6 +919,238 @@ func (m *MsgCreateResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *MsgExecute) 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 ErrIntOverflowTx + } + 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: MsgExecute: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgExecute: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Sender", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Sender = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Target", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Target = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Message", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Message = append(m.Message[:0], dAtA[iNdEx:postIndex]...) + if m.Message == nil { + m.Message = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgExecuteResponse) 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 ErrIntOverflowTx + } + 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: MsgExecuteResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgExecuteResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Response", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Response = append(m.Response[:0], dAtA[iNdEx:postIndex]...) + if m.Response == nil { + m.Response = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipTx(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 From fea3d31c569e0d95ef3620b5a6f3d0a6e4298850 Mon Sep 17 00:00:00 2001 From: unknown unknown Date: Mon, 4 Sep 2023 13:11:26 +0200 Subject: [PATCH 04/10] impl message server execute account logic --- x/accounts/account_test.go | 11 +++++ .../internal/implementation/api_builder.go | 14 ++---- .../implementation/implementation_test.go | 16 ------- x/accounts/msg_server.go | 47 +++++++++++++++++++ x/accounts/msg_server_test.go | 21 ++++++++- 5 files changed, 81 insertions(+), 28 deletions(-) diff --git a/x/accounts/account_test.go b/x/accounts/account_test.go index 8a3a427523fe..e6bcac74eb2d 100644 --- a/x/accounts/account_test.go +++ b/x/accounts/account_test.go @@ -2,8 +2,10 @@ package accounts import ( "context" + "strconv" "google.golang.org/protobuf/types/known/emptypb" + "google.golang.org/protobuf/types/known/wrapperspb" "cosmossdk.io/x/accounts/internal/implementation" ) @@ -22,6 +24,15 @@ func (t TestAccount) RegisterExecuteHandlers(builder *implementation.ExecuteBuil implementation.RegisterExecuteHandler(builder, func(_ context.Context, _ *emptypb.Empty) (*emptypb.Empty, error) { return &emptypb.Empty{}, nil }) + + implementation.RegisterExecuteHandler(builder, func(_ context.Context, req *wrapperspb.StringValue) (*wrapperspb.UInt64Value, error) { + value, err := strconv.ParseUint(req.Value, 10, 64) + if err != nil { + return nil, err + } + + return wrapperspb.UInt64(value), nil + }) } func (t TestAccount) RegisterQueryHandlers(builder *implementation.QueryBuilder) { diff --git a/x/accounts/internal/implementation/api_builder.go b/x/accounts/internal/implementation/api_builder.go index 3fae0c5e93df..18aba0241ea0 100644 --- a/x/accounts/internal/implementation/api_builder.go +++ b/x/accounts/internal/implementation/api_builder.go @@ -107,11 +107,8 @@ func (r *ExecuteBuilder) makeRequestDecoder() func(requestBytes []byte) (any, er return nil, err } - // check if part of the msg set - if _, exists := r.handlers[string(msg.ProtoReflect().Descriptor().FullName())]; !exists { - return nil, fmt.Errorf("%w: no handler for message %s", errInvalidMessage, string(msg.ProtoReflect().Descriptor().FullName())) - } - + // we do not check if it is part of a valid message set that an account can handle + // since the handler will do so. return msg, nil } } @@ -122,16 +119,13 @@ func (r *ExecuteBuilder) makeResponseEncoder() func(executeResponse any) ([]byte if !ok { return nil, fmt.Errorf("%w: expected protoreflect.Message, got %T", errInvalidMessage, executeResponse) } - - // check if part of the msg set - if _, exists := r.handlers[string(executeResponsePB.ProtoReflect().Descriptor().FullName())]; !exists { - return nil, fmt.Errorf("%w: not part of message set %s", errInvalidMessage, string(executeResponsePB.ProtoReflect().Descriptor().FullName())) - } anyPB, err := anypb.New(executeResponsePB) if err != nil { return nil, err } + // we do not check if it is part of an account's valid response message set + // as make handler will never allow for an invalid response to be returned. return proto.Marshal(anyPB) } } diff --git a/x/accounts/internal/implementation/implementation_test.go b/x/accounts/internal/implementation/implementation_test.go index ca98e526b9d6..af9cb4f4066b 100644 --- a/x/accounts/internal/implementation/implementation_test.go +++ b/x/accounts/internal/implementation/implementation_test.go @@ -106,16 +106,6 @@ func TestImplementation(t *testing.T) { require.True(t, proto.Equal(wantReq, gotReq.(protoreflect.ProtoMessage))) }) - t.Run("decode execute request - invalid message", func(t *testing.T) { - req := wrapperspb.Double(1) - anyPBReq, err := anypb.New(req) - require.NoError(t, err) - reqBytes, err := proto.Marshal(anyPBReq) - require.NoError(t, err) - _, err = impl.DecodeExecuteRequest(reqBytes) - require.ErrorIs(t, err, errInvalidMessage) - }) - t.Run("encode execute response - ok", func(t *testing.T) { resp := &wrapperspb.StringValue{Value: "test"} gotRespBytes, err := impl.EncodeExecuteResponse(resp) @@ -132,10 +122,4 @@ func TestImplementation(t *testing.T) { require.ErrorIs(t, err, errInvalidMessage) require.ErrorContains(t, err, "expected protoreflect.Message") }) - - t.Run("encode execute response - not part of the message set", func(t *testing.T) { - _, err := impl.EncodeExecuteResponse(&wrapperspb.DoubleValue{Value: 1}) - require.ErrorIs(t, err, errInvalidMessage) - require.ErrorContains(t, err, "not part of message set") - }) } diff --git a/x/accounts/msg_server.go b/x/accounts/msg_server.go index dd1aefac790d..2abd9a89c134 100644 --- a/x/accounts/msg_server.go +++ b/x/accounts/msg_server.go @@ -56,3 +56,50 @@ func (m msgServer) Create(ctx context.Context, request *v1.MsgCreate) (*v1.MsgCr Response: respBytes, }, nil } + +func (m msgServer) Execute(ctx context.Context, execute *v1.MsgExecute) (*v1.MsgExecuteResponse, error) { + // decode sender address + senderAddr, err := m.k.addressCodec.StringToBytes(execute.Sender) + if err != nil { + return nil, err + } + // decode the target address + targetAddr, err := m.k.addressCodec.StringToBytes(execute.Target) + if err != nil { + return nil, err + } + + // get account type + accType, err := m.k.AccountsByType.Get(ctx, targetAddr) + if err != nil { + return nil, err + } + + // get the implementation + impl, err := m.k.getImplementation(accType) + if err != nil { + return nil, err + } + + // decode message bytes into the concrete boxed message type + req, err := impl.DecodeExecuteRequest(execute.Message) + if err != nil { + return nil, err + } + + // run account execution logic + resp, err := m.k.Execute(ctx, targetAddr, senderAddr, req) + if err != nil { + return nil, err + } + + // encode the response + respBytes, err := impl.EncodeExecuteResponse(resp) + if err != nil { + return nil, err + } + + return &v1.MsgExecuteResponse{ + Response: respBytes, + }, nil +} diff --git a/x/accounts/msg_server_test.go b/x/accounts/msg_server_test.go index 875eea1e51d8..6af5ac896d22 100644 --- a/x/accounts/msg_server_test.go +++ b/x/accounts/msg_server_test.go @@ -7,7 +7,9 @@ import ( v1 "cosmossdk.io/x/accounts/v1" "github.com/stretchr/testify/require" "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/types/known/anypb" "google.golang.org/protobuf/types/known/emptypb" + "google.golang.org/protobuf/types/known/wrapperspb" ) func TestMsgServer(t *testing.T) { @@ -21,14 +23,29 @@ func TestMsgServer(t *testing.T) { initMsg, err := proto.Marshal(&emptypb.Empty{}) require.NoError(t, err) - resp, err := s.Create(ctx, &v1.MsgCreate{ + initResp, err := s.Create(ctx, &v1.MsgCreate{ Sender: "sender", AccountType: "test", Message: initMsg, }) require.NoError(t, err) - require.NotNil(t, resp) + require.NotNil(t, initResp) // execute + executeMsg := &wrapperspb.StringValue{ + Value: "10", + } + executeMsgAny, err := anypb.New(executeMsg) + require.NoError(t, err) + + executeMsgBytes, err := proto.Marshal(executeMsgAny) + require.NoError(t, err) + execResp, err := s.Execute(ctx, &v1.MsgExecute{ + Sender: "sender", + Target: initResp.AccountAddress, + Message: executeMsgBytes, + }) + require.NoError(t, err) + require.NotNil(t, execResp) } From 09dcd539947a862cc9a4206ddd48de0c7deb3ea2 Mon Sep 17 00:00:00 2001 From: unknown unknown Date: Mon, 4 Sep 2023 13:31:34 +0200 Subject: [PATCH 05/10] add query logic --- api/cosmos/accounts/v1/query.pulsar.go | 1095 ++++++++++++++++- api/cosmos/accounts/v1/query_grpc.pb.go | 52 +- proto/cosmos/accounts/v1/query.proto | 19 +- x/accounts/account_test.go | 4 + .../internal/implementation/implementation.go | 7 + x/accounts/keeper_test.go | 2 +- x/accounts/msg_server_test.go | 5 +- x/accounts/query_server.go | 58 + x/accounts/query_server_test.go | 57 + x/accounts/v1/query.pb.go | 573 ++++++++- 10 files changed, 1835 insertions(+), 37 deletions(-) create mode 100644 x/accounts/query_server.go create mode 100644 x/accounts/query_server_test.go diff --git a/api/cosmos/accounts/v1/query.pulsar.go b/api/cosmos/accounts/v1/query.pulsar.go index 09d041efd656..033d715c467e 100644 --- a/api/cosmos/accounts/v1/query.pulsar.go +++ b/api/cosmos/accounts/v1/query.pulsar.go @@ -2,11 +2,924 @@ package accountsv1 import ( + fmt "fmt" + runtime "github.com/cosmos/cosmos-proto/runtime" protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + io "io" reflect "reflect" + sync "sync" ) +var ( + md_AccountQueryRequest protoreflect.MessageDescriptor + fd_AccountQueryRequest_target protoreflect.FieldDescriptor + fd_AccountQueryRequest_request protoreflect.FieldDescriptor +) + +func init() { + file_cosmos_accounts_v1_query_proto_init() + md_AccountQueryRequest = File_cosmos_accounts_v1_query_proto.Messages().ByName("AccountQueryRequest") + fd_AccountQueryRequest_target = md_AccountQueryRequest.Fields().ByName("target") + fd_AccountQueryRequest_request = md_AccountQueryRequest.Fields().ByName("request") +} + +var _ protoreflect.Message = (*fastReflection_AccountQueryRequest)(nil) + +type fastReflection_AccountQueryRequest AccountQueryRequest + +func (x *AccountQueryRequest) ProtoReflect() protoreflect.Message { + return (*fastReflection_AccountQueryRequest)(x) +} + +func (x *AccountQueryRequest) slowProtoReflect() protoreflect.Message { + mi := &file_cosmos_accounts_v1_query_proto_msgTypes[0] + 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_AccountQueryRequest_messageType fastReflection_AccountQueryRequest_messageType +var _ protoreflect.MessageType = fastReflection_AccountQueryRequest_messageType{} + +type fastReflection_AccountQueryRequest_messageType struct{} + +func (x fastReflection_AccountQueryRequest_messageType) Zero() protoreflect.Message { + return (*fastReflection_AccountQueryRequest)(nil) +} +func (x fastReflection_AccountQueryRequest_messageType) New() protoreflect.Message { + return new(fastReflection_AccountQueryRequest) +} +func (x fastReflection_AccountQueryRequest_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_AccountQueryRequest +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_AccountQueryRequest) Descriptor() protoreflect.MessageDescriptor { + return md_AccountQueryRequest +} + +// 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_AccountQueryRequest) Type() protoreflect.MessageType { + return _fastReflection_AccountQueryRequest_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_AccountQueryRequest) New() protoreflect.Message { + return new(fastReflection_AccountQueryRequest) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_AccountQueryRequest) Interface() protoreflect.ProtoMessage { + return (*AccountQueryRequest)(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_AccountQueryRequest) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if x.Target != "" { + value := protoreflect.ValueOfString(x.Target) + if !f(fd_AccountQueryRequest_target, value) { + return + } + } + if len(x.Request) != 0 { + value := protoreflect.ValueOfBytes(x.Request) + if !f(fd_AccountQueryRequest_request, 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_AccountQueryRequest) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "cosmos.accounts.v1.AccountQueryRequest.target": + return x.Target != "" + case "cosmos.accounts.v1.AccountQueryRequest.request": + return len(x.Request) != 0 + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.v1.AccountQueryRequest")) + } + panic(fmt.Errorf("message cosmos.accounts.v1.AccountQueryRequest 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_AccountQueryRequest) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "cosmos.accounts.v1.AccountQueryRequest.target": + x.Target = "" + case "cosmos.accounts.v1.AccountQueryRequest.request": + x.Request = nil + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.v1.AccountQueryRequest")) + } + panic(fmt.Errorf("message cosmos.accounts.v1.AccountQueryRequest 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_AccountQueryRequest) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "cosmos.accounts.v1.AccountQueryRequest.target": + value := x.Target + return protoreflect.ValueOfString(value) + case "cosmos.accounts.v1.AccountQueryRequest.request": + value := x.Request + return protoreflect.ValueOfBytes(value) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.v1.AccountQueryRequest")) + } + panic(fmt.Errorf("message cosmos.accounts.v1.AccountQueryRequest 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_AccountQueryRequest) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "cosmos.accounts.v1.AccountQueryRequest.target": + x.Target = value.Interface().(string) + case "cosmos.accounts.v1.AccountQueryRequest.request": + x.Request = value.Bytes() + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.v1.AccountQueryRequest")) + } + panic(fmt.Errorf("message cosmos.accounts.v1.AccountQueryRequest 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_AccountQueryRequest) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "cosmos.accounts.v1.AccountQueryRequest.target": + panic(fmt.Errorf("field target of message cosmos.accounts.v1.AccountQueryRequest is not mutable")) + case "cosmos.accounts.v1.AccountQueryRequest.request": + panic(fmt.Errorf("field request of message cosmos.accounts.v1.AccountQueryRequest is not mutable")) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.v1.AccountQueryRequest")) + } + panic(fmt.Errorf("message cosmos.accounts.v1.AccountQueryRequest 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_AccountQueryRequest) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "cosmos.accounts.v1.AccountQueryRequest.target": + return protoreflect.ValueOfString("") + case "cosmos.accounts.v1.AccountQueryRequest.request": + return protoreflect.ValueOfBytes(nil) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.v1.AccountQueryRequest")) + } + panic(fmt.Errorf("message cosmos.accounts.v1.AccountQueryRequest 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_AccountQueryRequest) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in cosmos.accounts.v1.AccountQueryRequest", 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_AccountQueryRequest) 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_AccountQueryRequest) 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_AccountQueryRequest) 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_AccountQueryRequest) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*AccountQueryRequest) + if x == nil { + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: 0, + } + } + options := runtime.SizeInputToOptions(input) + _ = options + var n int + var l int + _ = l + l = len(x.Target) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + l = len(x.Request) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + if x.unknownFields != nil { + n += len(x.unknownFields) + } + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: n, + } + } + + marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) { + x := input.Message.Interface().(*AccountQueryRequest) + if x == nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + options := runtime.MarshalInputToOptions(input) + _ = options + size := options.Size(x) + dAtA := make([]byte, size) + i := len(dAtA) + _ = i + var l int + _ = l + if x.unknownFields != nil { + i -= len(x.unknownFields) + copy(dAtA[i:], x.unknownFields) + } + if len(x.Request) > 0 { + i -= len(x.Request) + copy(dAtA[i:], x.Request) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Request))) + i-- + dAtA[i] = 0x12 + } + if len(x.Target) > 0 { + i -= len(x.Target) + copy(dAtA[i:], x.Target) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Target))) + 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().(*AccountQueryRequest) + 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: AccountQueryRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: AccountQueryRequest: 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 Target", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.Target = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Request", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.Request = append(x.Request[:0], dAtA[iNdEx:postIndex]...) + if x.Request == nil { + x.Request = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := runtime.Skip(dAtA[iNdEx:]) + if err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if !options.DiscardUnknown { + x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + } + iNdEx += skippy + } + } + + if iNdEx > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil + } + return &protoiface.Methods{ + NoUnkeyedLiterals: struct{}{}, + Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown, + Size: size, + Marshal: marshal, + Unmarshal: unmarshal, + Merge: nil, + CheckInitialized: nil, + } +} + +var ( + md_AccountQueryResponse protoreflect.MessageDescriptor + fd_AccountQueryResponse_response protoreflect.FieldDescriptor +) + +func init() { + file_cosmos_accounts_v1_query_proto_init() + md_AccountQueryResponse = File_cosmos_accounts_v1_query_proto.Messages().ByName("AccountQueryResponse") + fd_AccountQueryResponse_response = md_AccountQueryResponse.Fields().ByName("response") +} + +var _ protoreflect.Message = (*fastReflection_AccountQueryResponse)(nil) + +type fastReflection_AccountQueryResponse AccountQueryResponse + +func (x *AccountQueryResponse) ProtoReflect() protoreflect.Message { + return (*fastReflection_AccountQueryResponse)(x) +} + +func (x *AccountQueryResponse) slowProtoReflect() protoreflect.Message { + mi := &file_cosmos_accounts_v1_query_proto_msgTypes[1] + 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_AccountQueryResponse_messageType fastReflection_AccountQueryResponse_messageType +var _ protoreflect.MessageType = fastReflection_AccountQueryResponse_messageType{} + +type fastReflection_AccountQueryResponse_messageType struct{} + +func (x fastReflection_AccountQueryResponse_messageType) Zero() protoreflect.Message { + return (*fastReflection_AccountQueryResponse)(nil) +} +func (x fastReflection_AccountQueryResponse_messageType) New() protoreflect.Message { + return new(fastReflection_AccountQueryResponse) +} +func (x fastReflection_AccountQueryResponse_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_AccountQueryResponse +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_AccountQueryResponse) Descriptor() protoreflect.MessageDescriptor { + return md_AccountQueryResponse +} + +// 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_AccountQueryResponse) Type() protoreflect.MessageType { + return _fastReflection_AccountQueryResponse_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_AccountQueryResponse) New() protoreflect.Message { + return new(fastReflection_AccountQueryResponse) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_AccountQueryResponse) Interface() protoreflect.ProtoMessage { + return (*AccountQueryResponse)(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_AccountQueryResponse) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if len(x.Response) != 0 { + value := protoreflect.ValueOfBytes(x.Response) + if !f(fd_AccountQueryResponse_response, 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_AccountQueryResponse) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "cosmos.accounts.v1.AccountQueryResponse.response": + return len(x.Response) != 0 + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.v1.AccountQueryResponse")) + } + panic(fmt.Errorf("message cosmos.accounts.v1.AccountQueryResponse 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_AccountQueryResponse) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "cosmos.accounts.v1.AccountQueryResponse.response": + x.Response = nil + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.v1.AccountQueryResponse")) + } + panic(fmt.Errorf("message cosmos.accounts.v1.AccountQueryResponse 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_AccountQueryResponse) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "cosmos.accounts.v1.AccountQueryResponse.response": + value := x.Response + return protoreflect.ValueOfBytes(value) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.v1.AccountQueryResponse")) + } + panic(fmt.Errorf("message cosmos.accounts.v1.AccountQueryResponse 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_AccountQueryResponse) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "cosmos.accounts.v1.AccountQueryResponse.response": + x.Response = value.Bytes() + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.v1.AccountQueryResponse")) + } + panic(fmt.Errorf("message cosmos.accounts.v1.AccountQueryResponse 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_AccountQueryResponse) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "cosmos.accounts.v1.AccountQueryResponse.response": + panic(fmt.Errorf("field response of message cosmos.accounts.v1.AccountQueryResponse is not mutable")) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.v1.AccountQueryResponse")) + } + panic(fmt.Errorf("message cosmos.accounts.v1.AccountQueryResponse 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_AccountQueryResponse) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "cosmos.accounts.v1.AccountQueryResponse.response": + return protoreflect.ValueOfBytes(nil) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.v1.AccountQueryResponse")) + } + panic(fmt.Errorf("message cosmos.accounts.v1.AccountQueryResponse 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_AccountQueryResponse) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in cosmos.accounts.v1.AccountQueryResponse", 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_AccountQueryResponse) 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_AccountQueryResponse) 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_AccountQueryResponse) 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_AccountQueryResponse) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*AccountQueryResponse) + if x == nil { + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: 0, + } + } + options := runtime.SizeInputToOptions(input) + _ = options + var n int + var l int + _ = l + l = len(x.Response) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + if x.unknownFields != nil { + n += len(x.unknownFields) + } + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: n, + } + } + + marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) { + x := input.Message.Interface().(*AccountQueryResponse) + if x == nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + options := runtime.MarshalInputToOptions(input) + _ = options + size := options.Size(x) + dAtA := make([]byte, size) + i := len(dAtA) + _ = i + var l int + _ = l + if x.unknownFields != nil { + i -= len(x.unknownFields) + copy(dAtA[i:], x.unknownFields) + } + if len(x.Response) > 0 { + i -= len(x.Response) + copy(dAtA[i:], x.Response) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Response))) + 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().(*AccountQueryResponse) + 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: AccountQueryResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: AccountQueryResponse: 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 Response", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.Response = append(x.Response[:0], dAtA[iNdEx:postIndex]...) + if x.Response == nil { + x.Response = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := runtime.Skip(dAtA[iNdEx:]) + if err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if !options.DiscardUnknown { + x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + } + iNdEx += skippy + } + } + + if iNdEx > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil + } + return &protoiface.Methods{ + NoUnkeyedLiterals: struct{}{}, + Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown, + Size: size, + Marshal: marshal, + Unmarshal: unmarshal, + Merge: nil, + CheckInitialized: nil, + } +} + // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.27.0 @@ -20,32 +933,147 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) +// AccountQueryRequest is the request type for the Query/AccountQuery RPC +type AccountQueryRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // target defines the account to be queried. + Target string `protobuf:"bytes,1,opt,name=target,proto3" json:"target,omitempty"` + // request defines the query message being sent to the account. + Request []byte `protobuf:"bytes,2,opt,name=request,proto3" json:"request,omitempty"` +} + +func (x *AccountQueryRequest) Reset() { + *x = AccountQueryRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_cosmos_accounts_v1_query_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *AccountQueryRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AccountQueryRequest) ProtoMessage() {} + +// Deprecated: Use AccountQueryRequest.ProtoReflect.Descriptor instead. +func (*AccountQueryRequest) Descriptor() ([]byte, []int) { + return file_cosmos_accounts_v1_query_proto_rawDescGZIP(), []int{0} +} + +func (x *AccountQueryRequest) GetTarget() string { + if x != nil { + return x.Target + } + return "" +} + +func (x *AccountQueryRequest) GetRequest() []byte { + if x != nil { + return x.Request + } + return nil +} + +// AccountQueryResponse is the response type for the Query/AccountQuery RPC method. +type AccountQueryResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // response defines the query response of the account. + Response []byte `protobuf:"bytes,1,opt,name=response,proto3" json:"response,omitempty"` +} + +func (x *AccountQueryResponse) Reset() { + *x = AccountQueryResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_cosmos_accounts_v1_query_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *AccountQueryResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AccountQueryResponse) ProtoMessage() {} + +// Deprecated: Use AccountQueryResponse.ProtoReflect.Descriptor instead. +func (*AccountQueryResponse) Descriptor() ([]byte, []int) { + return file_cosmos_accounts_v1_query_proto_rawDescGZIP(), []int{1} +} + +func (x *AccountQueryResponse) GetResponse() []byte { + if x != nil { + return x.Response + } + return nil +} + var File_cosmos_accounts_v1_query_proto protoreflect.FileDescriptor var file_cosmos_accounts_v1_query_proto_rawDesc = []byte{ 0x0a, 0x1e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2f, 0x76, 0x31, 0x2f, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x12, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, - 0x73, 0x2e, 0x76, 0x31, 0x32, 0x07, 0x0a, 0x05, 0x51, 0x75, 0x65, 0x72, 0x79, 0x42, 0xbe, 0x01, - 0x0a, 0x16, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x63, 0x63, - 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2e, 0x76, 0x31, 0x42, 0x0a, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, - 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x2e, 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, 0x76, 0x31, 0x3b, 0x61, 0x63, 0x63, 0x6f, - 0x75, 0x6e, 0x74, 0x73, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x41, 0x58, 0xaa, 0x02, 0x12, 0x43, - 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2e, 0x56, - 0x31, 0xca, 0x02, 0x12, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x41, 0x63, 0x63, 0x6f, 0x75, - 0x6e, 0x74, 0x73, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x1e, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, - 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, - 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x14, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, - 0x3a, 0x3a, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var file_cosmos_accounts_v1_query_proto_goTypes = []interface{}{} + 0x73, 0x2e, 0x76, 0x31, 0x22, 0x47, 0x0a, 0x13, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x51, + 0x75, 0x65, 0x72, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x74, + 0x61, 0x72, 0x67, 0x65, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x74, 0x61, 0x72, + 0x67, 0x65, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x32, 0x0a, + 0x14, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x51, 0x75, 0x65, 0x72, 0x79, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x08, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x32, 0x6c, 0x0a, 0x05, 0x51, 0x75, 0x65, 0x72, 0x79, 0x12, 0x63, 0x0a, 0x0c, 0x41, 0x63, + 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x51, 0x75, 0x65, 0x72, 0x79, 0x12, 0x27, 0x2e, 0x63, 0x6f, 0x73, + 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2e, 0x76, 0x31, 0x2e, + 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x51, 0x75, 0x65, 0x72, 0x79, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x28, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x63, 0x63, + 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, + 0x51, 0x75, 0x65, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, + 0xbe, 0x01, 0x0a, 0x16, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, + 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2e, 0x76, 0x31, 0x42, 0x0a, 0x51, 0x75, 0x65, 0x72, + 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x2e, 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, 0x76, 0x31, 0x3b, 0x61, 0x63, + 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x41, 0x58, 0xaa, 0x02, + 0x12, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, + 0x2e, 0x56, 0x31, 0xca, 0x02, 0x12, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x41, 0x63, 0x63, + 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x1e, 0x43, 0x6f, 0x73, 0x6d, 0x6f, + 0x73, 0x5c, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, + 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x14, 0x43, 0x6f, 0x73, 0x6d, + 0x6f, 0x73, 0x3a, 0x3a, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x3a, 0x3a, 0x56, 0x31, + 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_cosmos_accounts_v1_query_proto_rawDescOnce sync.Once + file_cosmos_accounts_v1_query_proto_rawDescData = file_cosmos_accounts_v1_query_proto_rawDesc +) + +func file_cosmos_accounts_v1_query_proto_rawDescGZIP() []byte { + file_cosmos_accounts_v1_query_proto_rawDescOnce.Do(func() { + file_cosmos_accounts_v1_query_proto_rawDescData = protoimpl.X.CompressGZIP(file_cosmos_accounts_v1_query_proto_rawDescData) + }) + return file_cosmos_accounts_v1_query_proto_rawDescData +} + +var file_cosmos_accounts_v1_query_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_cosmos_accounts_v1_query_proto_goTypes = []interface{}{ + (*AccountQueryRequest)(nil), // 0: cosmos.accounts.v1.AccountQueryRequest + (*AccountQueryResponse)(nil), // 1: cosmos.accounts.v1.AccountQueryResponse +} var file_cosmos_accounts_v1_query_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: cosmos.accounts.v1.Query.AccountQuery:input_type -> cosmos.accounts.v1.AccountQueryRequest + 1, // 1: cosmos.accounts.v1.Query.AccountQuery:output_type -> cosmos.accounts.v1.AccountQueryResponse + 1, // [1:2] is the sub-list for method output_type + 0, // [0:1] 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 @@ -56,18 +1084,45 @@ func file_cosmos_accounts_v1_query_proto_init() { if File_cosmos_accounts_v1_query_proto != nil { return } + if !protoimpl.UnsafeEnabled { + file_cosmos_accounts_v1_query_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*AccountQueryRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_cosmos_accounts_v1_query_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*AccountQueryResponse); 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{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_cosmos_accounts_v1_query_proto_rawDesc, NumEnums: 0, - NumMessages: 0, + NumMessages: 2, NumExtensions: 0, NumServices: 1, }, GoTypes: file_cosmos_accounts_v1_query_proto_goTypes, DependencyIndexes: file_cosmos_accounts_v1_query_proto_depIdxs, + MessageInfos: file_cosmos_accounts_v1_query_proto_msgTypes, }.Build() File_cosmos_accounts_v1_query_proto = out.File file_cosmos_accounts_v1_query_proto_rawDesc = nil diff --git a/api/cosmos/accounts/v1/query_grpc.pb.go b/api/cosmos/accounts/v1/query_grpc.pb.go index fb18e8fd4969..2d75c3703e13 100644 --- a/api/cosmos/accounts/v1/query_grpc.pb.go +++ b/api/cosmos/accounts/v1/query_grpc.pb.go @@ -7,7 +7,10 @@ package accountsv1 import ( + context "context" grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" ) // This is a compile-time assertion to ensure that this generated file @@ -15,12 +18,16 @@ import ( // Requires gRPC-Go v1.32.0 or later. const _ = grpc.SupportPackageIsVersion7 -const () +const ( + Query_AccountQuery_FullMethodName = "/cosmos.accounts.v1.Query/AccountQuery" +) // QueryClient is the client API for Query service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. type QueryClient interface { + // AccountQuery runs an account query. + AccountQuery(ctx context.Context, in *AccountQueryRequest, opts ...grpc.CallOption) (*AccountQueryResponse, error) } type queryClient struct { @@ -31,10 +38,21 @@ func NewQueryClient(cc grpc.ClientConnInterface) QueryClient { return &queryClient{cc} } +func (c *queryClient) AccountQuery(ctx context.Context, in *AccountQueryRequest, opts ...grpc.CallOption) (*AccountQueryResponse, error) { + out := new(AccountQueryResponse) + err := c.cc.Invoke(ctx, Query_AccountQuery_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // QueryServer is the server API for Query service. // All implementations must embed UnimplementedQueryServer // for forward compatibility type QueryServer interface { + // AccountQuery runs an account query. + AccountQuery(context.Context, *AccountQueryRequest) (*AccountQueryResponse, error) mustEmbedUnimplementedQueryServer() } @@ -42,6 +60,9 @@ type QueryServer interface { type UnimplementedQueryServer struct { } +func (UnimplementedQueryServer) AccountQuery(context.Context, *AccountQueryRequest) (*AccountQueryResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method AccountQuery not implemented") +} func (UnimplementedQueryServer) mustEmbedUnimplementedQueryServer() {} // UnsafeQueryServer may be embedded to opt out of forward compatibility for this service. @@ -55,13 +76,36 @@ func RegisterQueryServer(s grpc.ServiceRegistrar, srv QueryServer) { s.RegisterService(&Query_ServiceDesc, srv) } +func _Query_AccountQuery_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(AccountQueryRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).AccountQuery(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Query_AccountQuery_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).AccountQuery(ctx, req.(*AccountQueryRequest)) + } + return interceptor(ctx, in, info, handler) +} + // Query_ServiceDesc is the grpc.ServiceDesc for Query service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) var Query_ServiceDesc = grpc.ServiceDesc{ ServiceName: "cosmos.accounts.v1.Query", HandlerType: (*QueryServer)(nil), - Methods: []grpc.MethodDesc{}, - Streams: []grpc.StreamDesc{}, - Metadata: "cosmos/accounts/v1/query.proto", + Methods: []grpc.MethodDesc{ + { + MethodName: "AccountQuery", + Handler: _Query_AccountQuery_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "cosmos/accounts/v1/query.proto", } diff --git a/proto/cosmos/accounts/v1/query.proto b/proto/cosmos/accounts/v1/query.proto index 6d163414984d..ac8b6b716176 100644 --- a/proto/cosmos/accounts/v1/query.proto +++ b/proto/cosmos/accounts/v1/query.proto @@ -5,4 +5,21 @@ package cosmos.accounts.v1; option go_package = "cosmossdk.io/x/accounts/v1"; // Query defines the Query service for the x/accounts module. -service Query {} +service Query { + // AccountQuery runs an account query. + rpc AccountQuery(AccountQueryRequest) returns (AccountQueryResponse) {}; +} + +// AccountQueryRequest is the request type for the Query/AccountQuery RPC +message AccountQueryRequest { + // target defines the account to be queried. + string target = 1; + // request defines the query message being sent to the account. + bytes request = 2; +} + +// AccountQueryResponse is the response type for the Query/AccountQuery RPC method. +message AccountQueryResponse { + // response defines the query response of the account. + bytes response = 1; +} diff --git a/x/accounts/account_test.go b/x/accounts/account_test.go index e6bcac74eb2d..1377ba7a154d 100644 --- a/x/accounts/account_test.go +++ b/x/accounts/account_test.go @@ -39,4 +39,8 @@ func (t TestAccount) RegisterQueryHandlers(builder *implementation.QueryBuilder) implementation.RegisterQueryHandler(builder, func(_ context.Context, _ *emptypb.Empty) (*emptypb.Empty, error) { return &emptypb.Empty{}, nil }) + + implementation.RegisterQueryHandler(builder, func(_ context.Context, req *wrapperspb.UInt64Value) (*wrapperspb.StringValue, error) { + return wrapperspb.String(strconv.FormatUint(req.Value, 10)), nil + }) } diff --git a/x/accounts/internal/implementation/implementation.go b/x/accounts/internal/implementation/implementation.go index 4a517da69163..9b65e0692f49 100644 --- a/x/accounts/internal/implementation/implementation.go +++ b/x/accounts/internal/implementation/implementation.go @@ -35,6 +35,8 @@ func NewImplementation(account Account) (Implementation, error) { EncodeInitResponse: ir.encodeResponse, DecodeExecuteRequest: er.makeRequestDecoder(), EncodeExecuteResponse: er.makeResponseEncoder(), + DecodeQueryRequest: qr.er.makeRequestDecoder(), + EncodeQueryResponse: qr.er.makeResponseEncoder(), }, nil } @@ -59,4 +61,9 @@ type Implementation struct { DecodeExecuteRequest func([]byte) (any, error) // EncodeExecuteResponse encodes an execute response to be sent back from the message server. EncodeExecuteResponse func(any) ([]byte, error) + + // DecodeQueryRequest decodes a query request coming from the message server. + DecodeQueryRequest func([]byte) (any, error) + // EncodeQueryResponse encodes a query response to be sent back from the message server. + EncodeQueryResponse func(any) ([]byte, error) } diff --git a/x/accounts/keeper_test.go b/x/accounts/keeper_test.go index 23f3431c2451..e8c68aca2356 100644 --- a/x/accounts/keeper_test.go +++ b/x/accounts/keeper_test.go @@ -4,12 +4,12 @@ import ( "context" "testing" - "cosmossdk.io/core/address" "github.com/stretchr/testify/require" "google.golang.org/protobuf/types/known/emptypb" "cosmossdk.io/collections" "cosmossdk.io/collections/colltest" + "cosmossdk.io/core/address" "cosmossdk.io/x/accounts/internal/implementation" ) diff --git a/x/accounts/msg_server_test.go b/x/accounts/msg_server_test.go index 6af5ac896d22..1a1b0667ceb0 100644 --- a/x/accounts/msg_server_test.go +++ b/x/accounts/msg_server_test.go @@ -3,13 +3,14 @@ package accounts import ( "testing" - "cosmossdk.io/x/accounts/internal/implementation" - v1 "cosmossdk.io/x/accounts/v1" "github.com/stretchr/testify/require" "google.golang.org/protobuf/proto" "google.golang.org/protobuf/types/known/anypb" "google.golang.org/protobuf/types/known/emptypb" "google.golang.org/protobuf/types/known/wrapperspb" + + "cosmossdk.io/x/accounts/internal/implementation" + v1 "cosmossdk.io/x/accounts/v1" ) func TestMsgServer(t *testing.T) { diff --git a/x/accounts/query_server.go b/x/accounts/query_server.go new file mode 100644 index 000000000000..03ec7bea3b82 --- /dev/null +++ b/x/accounts/query_server.go @@ -0,0 +1,58 @@ +package accounts + +import ( + "context" + + v1 "cosmossdk.io/x/accounts/v1" +) + +var _ v1.QueryServer = queryServer{} + +func NewQueryServer(k Keeper) v1.QueryServer { + return &queryServer{k} +} + +type queryServer struct { + k Keeper +} + +func (q queryServer) AccountQuery(ctx context.Context, request *v1.AccountQueryRequest) (*v1.AccountQueryResponse, error) { + // get target addr + targetAddr, err := q.k.addressCodec.StringToBytes(request.Target) + if err != nil { + return nil, err + } + + // get acc type + accType, err := q.k.AccountsByType.Get(ctx, targetAddr) + if err != nil { + return nil, err + } + + // get impl + impl, err := q.k.getImplementation(accType) + if err != nil { + return nil, err + } + + // decode req into boxed concrete type + queryReq, err := impl.DecodeQueryRequest(request.Request) + if err != nil { + return nil, err + } + // run query + resp, err := q.k.Query(ctx, targetAddr, queryReq) + if err != nil { + return nil, err + } + + // encode response + respBytes, err := impl.EncodeQueryResponse(resp) + if err != nil { + return nil, err + } + + return &v1.AccountQueryResponse{ + Response: respBytes, + }, nil +} diff --git a/x/accounts/query_server_test.go b/x/accounts/query_server_test.go new file mode 100644 index 000000000000..a04570f6abee --- /dev/null +++ b/x/accounts/query_server_test.go @@ -0,0 +1,57 @@ +package accounts + +import ( + "testing" + + "github.com/stretchr/testify/require" + "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/types/known/anypb" + "google.golang.org/protobuf/types/known/emptypb" + "google.golang.org/protobuf/types/known/wrapperspb" + + "cosmossdk.io/x/accounts/internal/implementation" + v1 "cosmossdk.io/x/accounts/v1" +) + +func TestQueryServer(t *testing.T) { + k, ctx := newKeeper(t, map[string]implementation.Account{ + "test": TestAccount{}, + }) + + ms := NewMsgServer(k) + qs := NewQueryServer(k) + + // create + initMsg, err := proto.Marshal(&emptypb.Empty{}) + require.NoError(t, err) + + initResp, err := ms.Create(ctx, &v1.MsgCreate{ + Sender: "sender", + AccountType: "test", + Message: initMsg, + }) + require.NoError(t, err) + + // query + req := &wrapperspb.UInt64Value{Value: 10} + anypbReq, err := anypb.New(req) + require.NoError(t, err) + + anypbReqBytes, err := proto.Marshal(anypbReq) + require.NoError(t, err) + + queryResp, err := qs.AccountQuery(ctx, &v1.AccountQueryRequest{ + Target: initResp.AccountAddress, + Request: anypbReqBytes, + }) + require.NoError(t, err) + + respAnyPB := &anypb.Any{} + err = proto.Unmarshal(queryResp.Response, respAnyPB) + require.NoError(t, err) + + resp, err := respAnyPB.UnmarshalNew() + require.NoError(t, err) + + require.Equal(t, "10", resp.(*wrapperspb.StringValue).Value) +} diff --git a/x/accounts/v1/query.pb.go b/x/accounts/v1/query.pb.go index a53c86fcc6f2..f3c7cd495135 100644 --- a/x/accounts/v1/query.pb.go +++ b/x/accounts/v1/query.pb.go @@ -9,7 +9,11 @@ import ( grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" math "math" + math_bits "math/bits" ) // Reference imports to suppress errors if they are not otherwise used. @@ -23,18 +27,130 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package +// AccountQueryRequest is the request type for the Query/AccountQuery RPC +type AccountQueryRequest struct { + // target defines the account to be queried. + Target string `protobuf:"bytes,1,opt,name=target,proto3" json:"target,omitempty"` + // request defines the query message being sent to the account. + Request []byte `protobuf:"bytes,2,opt,name=request,proto3" json:"request,omitempty"` +} + +func (m *AccountQueryRequest) Reset() { *m = AccountQueryRequest{} } +func (m *AccountQueryRequest) String() string { return proto.CompactTextString(m) } +func (*AccountQueryRequest) ProtoMessage() {} +func (*AccountQueryRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_16ad14c22e3080d2, []int{0} +} +func (m *AccountQueryRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *AccountQueryRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_AccountQueryRequest.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 *AccountQueryRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_AccountQueryRequest.Merge(m, src) +} +func (m *AccountQueryRequest) XXX_Size() int { + return m.Size() +} +func (m *AccountQueryRequest) XXX_DiscardUnknown() { + xxx_messageInfo_AccountQueryRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_AccountQueryRequest proto.InternalMessageInfo + +func (m *AccountQueryRequest) GetTarget() string { + if m != nil { + return m.Target + } + return "" +} + +func (m *AccountQueryRequest) GetRequest() []byte { + if m != nil { + return m.Request + } + return nil +} + +// AccountQueryResponse is the response type for the Query/AccountQuery RPC method. +type AccountQueryResponse struct { + // response defines the query response of the account. + Response []byte `protobuf:"bytes,1,opt,name=response,proto3" json:"response,omitempty"` +} + +func (m *AccountQueryResponse) Reset() { *m = AccountQueryResponse{} } +func (m *AccountQueryResponse) String() string { return proto.CompactTextString(m) } +func (*AccountQueryResponse) ProtoMessage() {} +func (*AccountQueryResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_16ad14c22e3080d2, []int{1} +} +func (m *AccountQueryResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *AccountQueryResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_AccountQueryResponse.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 *AccountQueryResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_AccountQueryResponse.Merge(m, src) +} +func (m *AccountQueryResponse) XXX_Size() int { + return m.Size() +} +func (m *AccountQueryResponse) XXX_DiscardUnknown() { + xxx_messageInfo_AccountQueryResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_AccountQueryResponse proto.InternalMessageInfo + +func (m *AccountQueryResponse) GetResponse() []byte { + if m != nil { + return m.Response + } + return nil +} + +func init() { + proto.RegisterType((*AccountQueryRequest)(nil), "cosmos.accounts.v1.AccountQueryRequest") + proto.RegisterType((*AccountQueryResponse)(nil), "cosmos.accounts.v1.AccountQueryResponse") +} + func init() { proto.RegisterFile("cosmos/accounts/v1/query.proto", fileDescriptor_16ad14c22e3080d2) } var fileDescriptor_16ad14c22e3080d2 = []byte{ - // 120 bytes of a gzipped FileDescriptorProto + // 219 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4b, 0xce, 0x2f, 0xce, 0xcd, 0x2f, 0xd6, 0x4f, 0x4c, 0x4e, 0xce, 0x2f, 0xcd, 0x2b, 0x29, 0xd6, 0x2f, 0x33, 0xd4, 0x2f, 0x2c, 0x4d, 0x2d, 0xaa, 0xd4, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x82, 0xc8, 0xeb, 0xc1, - 0xe4, 0xf5, 0xca, 0x0c, 0x8d, 0xd8, 0xb9, 0x58, 0x03, 0x41, 0x4a, 0x9c, 0x4c, 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, 0x0a, 0xa2, 0xad, 0x38, 0x25, 0x5b, 0x2f, 0x33, - 0x5f, 0xbf, 0x02, 0xd9, 0xf8, 0x24, 0x36, 0xb0, 0xc9, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, - 0x25, 0xf2, 0xcc, 0xc1, 0x7b, 0x00, 0x00, 0x00, + 0xe4, 0xf5, 0xca, 0x0c, 0x95, 0xdc, 0xb9, 0x84, 0x1d, 0x21, 0xdc, 0x40, 0x90, 0xca, 0xa0, 0xd4, + 0xc2, 0xd2, 0xd4, 0xe2, 0x12, 0x21, 0x31, 0x2e, 0xb6, 0x92, 0xc4, 0xa2, 0xf4, 0xd4, 0x12, 0x09, + 0x46, 0x05, 0x46, 0x0d, 0xce, 0x20, 0x28, 0x4f, 0x48, 0x82, 0x8b, 0xbd, 0x08, 0xa2, 0x44, 0x82, + 0x49, 0x81, 0x51, 0x83, 0x27, 0x08, 0xc6, 0x55, 0x32, 0xe2, 0x12, 0x41, 0x35, 0xa8, 0xb8, 0x20, + 0x3f, 0xaf, 0x38, 0x55, 0x48, 0x8a, 0x8b, 0xa3, 0x08, 0xca, 0x06, 0x9b, 0xc5, 0x13, 0x04, 0xe7, + 0x1b, 0xe5, 0x70, 0xb1, 0x82, 0x15, 0x0b, 0x25, 0x73, 0xf1, 0x20, 0x6b, 0x16, 0x52, 0xd7, 0xc3, + 0x74, 0xaa, 0x1e, 0x16, 0x77, 0x4a, 0x69, 0x10, 0x56, 0x08, 0xb1, 0x4b, 0x89, 0xc1, 0xc9, 0xe4, + 0xc4, 0x23, 0x39, 0xc6, 0x0b, 0x8f, 0xe4, 0x18, 0x1f, 0x3c, 0x92, 0x63, 0x9c, 0xf0, 0x58, 0x8e, + 0xe1, 0xc2, 0x63, 0x39, 0x86, 0x1b, 0x8f, 0xe5, 0x18, 0xa2, 0xa4, 0x20, 0x86, 0x14, 0xa7, 0x64, + 0xeb, 0x65, 0xe6, 0xeb, 0x57, 0x20, 0x07, 0x60, 0x12, 0x1b, 0x38, 0xec, 0x8c, 0x01, 0x01, 0x00, + 0x00, 0xff, 0xff, 0xdf, 0xce, 0x73, 0x6a, 0x5d, 0x01, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -49,6 +165,8 @@ const _ = grpc.SupportPackageIsVersion4 // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. type QueryClient interface { + // AccountQuery runs an account query. + AccountQuery(ctx context.Context, in *AccountQueryRequest, opts ...grpc.CallOption) (*AccountQueryResponse, error) } type queryClient struct { @@ -59,22 +177,459 @@ func NewQueryClient(cc grpc1.ClientConn) QueryClient { return &queryClient{cc} } +func (c *queryClient) AccountQuery(ctx context.Context, in *AccountQueryRequest, opts ...grpc.CallOption) (*AccountQueryResponse, error) { + out := new(AccountQueryResponse) + err := c.cc.Invoke(ctx, "/cosmos.accounts.v1.Query/AccountQuery", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // QueryServer is the server API for Query service. type QueryServer interface { + // AccountQuery runs an account query. + AccountQuery(context.Context, *AccountQueryRequest) (*AccountQueryResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. type UnimplementedQueryServer struct { } +func (*UnimplementedQueryServer) AccountQuery(ctx context.Context, req *AccountQueryRequest) (*AccountQueryResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method AccountQuery not implemented") +} + func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) } +func _Query_AccountQuery_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(AccountQueryRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).AccountQuery(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/cosmos.accounts.v1.Query/AccountQuery", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).AccountQuery(ctx, req.(*AccountQueryRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "cosmos.accounts.v1.Query", HandlerType: (*QueryServer)(nil), - Methods: []grpc.MethodDesc{}, - Streams: []grpc.StreamDesc{}, - Metadata: "cosmos/accounts/v1/query.proto", + Methods: []grpc.MethodDesc{ + { + MethodName: "AccountQuery", + Handler: _Query_AccountQuery_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "cosmos/accounts/v1/query.proto", +} + +func (m *AccountQueryRequest) 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 *AccountQueryRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *AccountQueryRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Request) > 0 { + i -= len(m.Request) + copy(dAtA[i:], m.Request) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Request))) + i-- + dAtA[i] = 0x12 + } + if len(m.Target) > 0 { + i -= len(m.Target) + copy(dAtA[i:], m.Target) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Target))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *AccountQueryResponse) 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 *AccountQueryResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *AccountQueryResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Response) > 0 { + i -= len(m.Response) + copy(dAtA[i:], m.Response) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Response))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil } + +func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { + offset -= sovQuery(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *AccountQueryRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Target) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.Request) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *AccountQueryResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Response) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func sovQuery(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozQuery(x uint64) (n int) { + return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *AccountQueryRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: AccountQueryRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: AccountQueryRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Target", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Target = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Request", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Request = append(m.Request[:0], dAtA[iNdEx:postIndex]...) + if m.Request == nil { + m.Request = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *AccountQueryResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: AccountQueryResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: AccountQueryResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Response", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Response = append(m.Response[:0], dAtA[iNdEx:postIndex]...) + if m.Response == nil { + m.Response = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipQuery(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthQuery + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupQuery + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthQuery + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthQuery = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowQuery = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupQuery = fmt.Errorf("proto: unexpected end of group") +) From b27bc73ccaa2ac4d28bcb7b327120fac0e5f2e8b Mon Sep 17 00:00:00 2001 From: testinginprod <98415576+testinginprod@users.noreply.github.com> Date: Tue, 5 Sep 2023 14:13:55 +0200 Subject: [PATCH 06/10] Update proto/cosmos/accounts/v1/tx.proto Co-authored-by: samricotta <37125168+samricotta@users.noreply.github.com> --- proto/cosmos/accounts/v1/tx.proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proto/cosmos/accounts/v1/tx.proto b/proto/cosmos/accounts/v1/tx.proto index 28bce1da89e6..32870fa869da 100644 --- a/proto/cosmos/accounts/v1/tx.proto +++ b/proto/cosmos/accounts/v1/tx.proto @@ -6,7 +6,7 @@ option go_package = "cosmossdk.io/x/accounts/v1"; // Msg defines the Msg service for the x/accounts module. service Msg { - // Create creates a new account in the chain. + // 'Create' creates a new account in the chain. rpc Create(MsgCreate) returns (MsgCreateResponse); // Execute executes a message to the target account. From c483aff61d6219a525992ba173d71ba4852a9924 Mon Sep 17 00:00:00 2001 From: testinginprod <98415576+testinginprod@users.noreply.github.com> Date: Tue, 5 Sep 2023 14:14:03 +0200 Subject: [PATCH 07/10] Update proto/cosmos/accounts/v1/tx.proto Co-authored-by: samricotta <37125168+samricotta@users.noreply.github.com> --- proto/cosmos/accounts/v1/tx.proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proto/cosmos/accounts/v1/tx.proto b/proto/cosmos/accounts/v1/tx.proto index 32870fa869da..4446c4c4746e 100644 --- a/proto/cosmos/accounts/v1/tx.proto +++ b/proto/cosmos/accounts/v1/tx.proto @@ -9,7 +9,7 @@ service Msg { // 'Create' creates a new account in the chain. rpc Create(MsgCreate) returns (MsgCreateResponse); - // Execute executes a message to the target account. + // `Execute` executes a message to the target account. rpc Execute(MsgExecute) returns (MsgExecuteResponse); } From 95974bce6521c2ba04eed06933e4631e3daf093f Mon Sep 17 00:00:00 2001 From: testinginprod <98415576+testinginprod@users.noreply.github.com> Date: Tue, 5 Sep 2023 14:14:10 +0200 Subject: [PATCH 08/10] Update x/accounts/internal/implementation/api_builder.go Co-authored-by: samricotta <37125168+samricotta@users.noreply.github.com> --- x/accounts/internal/implementation/api_builder.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/accounts/internal/implementation/api_builder.go b/x/accounts/internal/implementation/api_builder.go index 18aba0241ea0..76ef4a7b15d1 100644 --- a/x/accounts/internal/implementation/api_builder.go +++ b/x/accounts/internal/implementation/api_builder.go @@ -107,7 +107,7 @@ func (r *ExecuteBuilder) makeRequestDecoder() func(requestBytes []byte) (any, er return nil, err } - // we do not check if it is part of a valid message set that an account can handle + // we do not check if it is part of a valid message set as an account can handle // since the handler will do so. return msg, nil } From 3e6fb44a403a2d05734868f90a674b480397dc42 Mon Sep 17 00:00:00 2001 From: testinginprod <98415576+testinginprod@users.noreply.github.com> Date: Tue, 5 Sep 2023 14:14:17 +0200 Subject: [PATCH 09/10] Update x/accounts/internal/implementation/api_builder.go Co-authored-by: samricotta <37125168+samricotta@users.noreply.github.com> --- x/accounts/internal/implementation/api_builder.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/accounts/internal/implementation/api_builder.go b/x/accounts/internal/implementation/api_builder.go index 76ef4a7b15d1..ca376e54cfab 100644 --- a/x/accounts/internal/implementation/api_builder.go +++ b/x/accounts/internal/implementation/api_builder.go @@ -108,7 +108,7 @@ func (r *ExecuteBuilder) makeRequestDecoder() func(requestBytes []byte) (any, er } // we do not check if it is part of a valid message set as an account can handle - // since the handler will do so. + // and the handler will do so. return msg, nil } } From afac2ad6ffc6e3bb3769c66999b9f1482e80d88b Mon Sep 17 00:00:00 2001 From: unknown unknown Date: Tue, 5 Sep 2023 15:36:21 +0200 Subject: [PATCH 10/10] rename Create to Init --- api/cosmos/accounts/v1/tx.pulsar.go | 457 +++++++++++++-------------- api/cosmos/accounts/v1/tx_grpc.pb.go | 34 +- proto/cosmos/accounts/v1/tx.proto | 14 +- x/accounts/keeper.go | 4 +- x/accounts/keeper_test.go | 8 +- x/accounts/msg_server.go | 6 +- x/accounts/msg_server_test.go | 2 +- x/accounts/query_server_test.go | 2 +- x/accounts/v1/tx.pb.go | 176 +++++------ 9 files changed, 351 insertions(+), 352 deletions(-) diff --git a/api/cosmos/accounts/v1/tx.pulsar.go b/api/cosmos/accounts/v1/tx.pulsar.go index cb520cdb7e17..835114b965e5 100644 --- a/api/cosmos/accounts/v1/tx.pulsar.go +++ b/api/cosmos/accounts/v1/tx.pulsar.go @@ -13,29 +13,29 @@ import ( ) var ( - md_MsgCreate protoreflect.MessageDescriptor - fd_MsgCreate_sender protoreflect.FieldDescriptor - fd_MsgCreate_account_type protoreflect.FieldDescriptor - fd_MsgCreate_message protoreflect.FieldDescriptor + md_MsgInit protoreflect.MessageDescriptor + fd_MsgInit_sender protoreflect.FieldDescriptor + fd_MsgInit_account_type protoreflect.FieldDescriptor + fd_MsgInit_message protoreflect.FieldDescriptor ) func init() { file_cosmos_accounts_v1_tx_proto_init() - md_MsgCreate = File_cosmos_accounts_v1_tx_proto.Messages().ByName("MsgCreate") - fd_MsgCreate_sender = md_MsgCreate.Fields().ByName("sender") - fd_MsgCreate_account_type = md_MsgCreate.Fields().ByName("account_type") - fd_MsgCreate_message = md_MsgCreate.Fields().ByName("message") + md_MsgInit = File_cosmos_accounts_v1_tx_proto.Messages().ByName("MsgInit") + fd_MsgInit_sender = md_MsgInit.Fields().ByName("sender") + fd_MsgInit_account_type = md_MsgInit.Fields().ByName("account_type") + fd_MsgInit_message = md_MsgInit.Fields().ByName("message") } -var _ protoreflect.Message = (*fastReflection_MsgCreate)(nil) +var _ protoreflect.Message = (*fastReflection_MsgInit)(nil) -type fastReflection_MsgCreate MsgCreate +type fastReflection_MsgInit MsgInit -func (x *MsgCreate) ProtoReflect() protoreflect.Message { - return (*fastReflection_MsgCreate)(x) +func (x *MsgInit) ProtoReflect() protoreflect.Message { + return (*fastReflection_MsgInit)(x) } -func (x *MsgCreate) slowProtoReflect() protoreflect.Message { +func (x *MsgInit) slowProtoReflect() protoreflect.Message { mi := &file_cosmos_accounts_v1_tx_proto_msgTypes[0] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -47,43 +47,43 @@ func (x *MsgCreate) slowProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -var _fastReflection_MsgCreate_messageType fastReflection_MsgCreate_messageType -var _ protoreflect.MessageType = fastReflection_MsgCreate_messageType{} +var _fastReflection_MsgInit_messageType fastReflection_MsgInit_messageType +var _ protoreflect.MessageType = fastReflection_MsgInit_messageType{} -type fastReflection_MsgCreate_messageType struct{} +type fastReflection_MsgInit_messageType struct{} -func (x fastReflection_MsgCreate_messageType) Zero() protoreflect.Message { - return (*fastReflection_MsgCreate)(nil) +func (x fastReflection_MsgInit_messageType) Zero() protoreflect.Message { + return (*fastReflection_MsgInit)(nil) } -func (x fastReflection_MsgCreate_messageType) New() protoreflect.Message { - return new(fastReflection_MsgCreate) +func (x fastReflection_MsgInit_messageType) New() protoreflect.Message { + return new(fastReflection_MsgInit) } -func (x fastReflection_MsgCreate_messageType) Descriptor() protoreflect.MessageDescriptor { - return md_MsgCreate +func (x fastReflection_MsgInit_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_MsgInit } // Descriptor returns message descriptor, which contains only the protobuf // type information for the message. -func (x *fastReflection_MsgCreate) Descriptor() protoreflect.MessageDescriptor { - return md_MsgCreate +func (x *fastReflection_MsgInit) Descriptor() protoreflect.MessageDescriptor { + return md_MsgInit } // 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_MsgCreate) Type() protoreflect.MessageType { - return _fastReflection_MsgCreate_messageType +func (x *fastReflection_MsgInit) Type() protoreflect.MessageType { + return _fastReflection_MsgInit_messageType } // New returns a newly allocated and mutable empty message. -func (x *fastReflection_MsgCreate) New() protoreflect.Message { - return new(fastReflection_MsgCreate) +func (x *fastReflection_MsgInit) New() protoreflect.Message { + return new(fastReflection_MsgInit) } // Interface unwraps the message reflection interface and // returns the underlying ProtoMessage interface. -func (x *fastReflection_MsgCreate) Interface() protoreflect.ProtoMessage { - return (*MsgCreate)(x) +func (x *fastReflection_MsgInit) Interface() protoreflect.ProtoMessage { + return (*MsgInit)(x) } // Range iterates over every populated field in an undefined order, @@ -91,22 +91,22 @@ func (x *fastReflection_MsgCreate) Interface() protoreflect.ProtoMessage { // Range returns immediately if f returns false. // While iterating, mutating operations may only be performed // on the current field descriptor. -func (x *fastReflection_MsgCreate) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { +func (x *fastReflection_MsgInit) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { if x.Sender != "" { value := protoreflect.ValueOfString(x.Sender) - if !f(fd_MsgCreate_sender, value) { + if !f(fd_MsgInit_sender, value) { return } } if x.AccountType != "" { value := protoreflect.ValueOfString(x.AccountType) - if !f(fd_MsgCreate_account_type, value) { + if !f(fd_MsgInit_account_type, value) { return } } if len(x.Message) != 0 { value := protoreflect.ValueOfBytes(x.Message) - if !f(fd_MsgCreate_message, value) { + if !f(fd_MsgInit_message, value) { return } } @@ -123,19 +123,19 @@ func (x *fastReflection_MsgCreate) Range(f func(protoreflect.FieldDescriptor, pr // 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_MsgCreate) Has(fd protoreflect.FieldDescriptor) bool { +func (x *fastReflection_MsgInit) Has(fd protoreflect.FieldDescriptor) bool { switch fd.FullName() { - case "cosmos.accounts.v1.MsgCreate.sender": + case "cosmos.accounts.v1.MsgInit.sender": return x.Sender != "" - case "cosmos.accounts.v1.MsgCreate.account_type": + case "cosmos.accounts.v1.MsgInit.account_type": return x.AccountType != "" - case "cosmos.accounts.v1.MsgCreate.message": + case "cosmos.accounts.v1.MsgInit.message": return len(x.Message) != 0 default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.v1.MsgCreate")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.v1.MsgInit")) } - panic(fmt.Errorf("message cosmos.accounts.v1.MsgCreate does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message cosmos.accounts.v1.MsgInit does not contain field %s", fd.FullName())) } } @@ -145,19 +145,19 @@ func (x *fastReflection_MsgCreate) Has(fd protoreflect.FieldDescriptor) bool { // associated with the given field number. // // Clear is a mutating operation and unsafe for concurrent use. -func (x *fastReflection_MsgCreate) Clear(fd protoreflect.FieldDescriptor) { +func (x *fastReflection_MsgInit) Clear(fd protoreflect.FieldDescriptor) { switch fd.FullName() { - case "cosmos.accounts.v1.MsgCreate.sender": + case "cosmos.accounts.v1.MsgInit.sender": x.Sender = "" - case "cosmos.accounts.v1.MsgCreate.account_type": + case "cosmos.accounts.v1.MsgInit.account_type": x.AccountType = "" - case "cosmos.accounts.v1.MsgCreate.message": + case "cosmos.accounts.v1.MsgInit.message": x.Message = nil default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.v1.MsgCreate")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.v1.MsgInit")) } - panic(fmt.Errorf("message cosmos.accounts.v1.MsgCreate does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message cosmos.accounts.v1.MsgInit does not contain field %s", fd.FullName())) } } @@ -167,22 +167,22 @@ func (x *fastReflection_MsgCreate) Clear(fd protoreflect.FieldDescriptor) { // the default value of a bytes scalar is guaranteed to be a copy. // For unpopulated composite types, it returns an empty, read-only view // of the value; to obtain a mutable reference, use Mutable. -func (x *fastReflection_MsgCreate) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { +func (x *fastReflection_MsgInit) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { switch descriptor.FullName() { - case "cosmos.accounts.v1.MsgCreate.sender": + case "cosmos.accounts.v1.MsgInit.sender": value := x.Sender return protoreflect.ValueOfString(value) - case "cosmos.accounts.v1.MsgCreate.account_type": + case "cosmos.accounts.v1.MsgInit.account_type": value := x.AccountType return protoreflect.ValueOfString(value) - case "cosmos.accounts.v1.MsgCreate.message": + case "cosmos.accounts.v1.MsgInit.message": value := x.Message return protoreflect.ValueOfBytes(value) default: if descriptor.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.v1.MsgCreate")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.v1.MsgInit")) } - panic(fmt.Errorf("message cosmos.accounts.v1.MsgCreate does not contain field %s", descriptor.FullName())) + panic(fmt.Errorf("message cosmos.accounts.v1.MsgInit does not contain field %s", descriptor.FullName())) } } @@ -196,19 +196,19 @@ func (x *fastReflection_MsgCreate) Get(descriptor protoreflect.FieldDescriptor) // empty, read-only value, then it panics. // // Set is a mutating operation and unsafe for concurrent use. -func (x *fastReflection_MsgCreate) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { +func (x *fastReflection_MsgInit) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { switch fd.FullName() { - case "cosmos.accounts.v1.MsgCreate.sender": + case "cosmos.accounts.v1.MsgInit.sender": x.Sender = value.Interface().(string) - case "cosmos.accounts.v1.MsgCreate.account_type": + case "cosmos.accounts.v1.MsgInit.account_type": x.AccountType = value.Interface().(string) - case "cosmos.accounts.v1.MsgCreate.message": + case "cosmos.accounts.v1.MsgInit.message": x.Message = value.Bytes() default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.v1.MsgCreate")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.v1.MsgInit")) } - panic(fmt.Errorf("message cosmos.accounts.v1.MsgCreate does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message cosmos.accounts.v1.MsgInit does not contain field %s", fd.FullName())) } } @@ -222,48 +222,48 @@ func (x *fastReflection_MsgCreate) Set(fd protoreflect.FieldDescriptor, value pr // It panics if the field does not contain a composite type. // // Mutable is a mutating operation and unsafe for concurrent use. -func (x *fastReflection_MsgCreate) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { +func (x *fastReflection_MsgInit) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { switch fd.FullName() { - case "cosmos.accounts.v1.MsgCreate.sender": - panic(fmt.Errorf("field sender of message cosmos.accounts.v1.MsgCreate is not mutable")) - case "cosmos.accounts.v1.MsgCreate.account_type": - panic(fmt.Errorf("field account_type of message cosmos.accounts.v1.MsgCreate is not mutable")) - case "cosmos.accounts.v1.MsgCreate.message": - panic(fmt.Errorf("field message of message cosmos.accounts.v1.MsgCreate is not mutable")) + case "cosmos.accounts.v1.MsgInit.sender": + panic(fmt.Errorf("field sender of message cosmos.accounts.v1.MsgInit is not mutable")) + case "cosmos.accounts.v1.MsgInit.account_type": + panic(fmt.Errorf("field account_type of message cosmos.accounts.v1.MsgInit is not mutable")) + case "cosmos.accounts.v1.MsgInit.message": + panic(fmt.Errorf("field message of message cosmos.accounts.v1.MsgInit is not mutable")) default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.v1.MsgCreate")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.v1.MsgInit")) } - panic(fmt.Errorf("message cosmos.accounts.v1.MsgCreate does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message cosmos.accounts.v1.MsgInit 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_MsgCreate) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { +func (x *fastReflection_MsgInit) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { switch fd.FullName() { - case "cosmos.accounts.v1.MsgCreate.sender": + case "cosmos.accounts.v1.MsgInit.sender": return protoreflect.ValueOfString("") - case "cosmos.accounts.v1.MsgCreate.account_type": + case "cosmos.accounts.v1.MsgInit.account_type": return protoreflect.ValueOfString("") - case "cosmos.accounts.v1.MsgCreate.message": + case "cosmos.accounts.v1.MsgInit.message": return protoreflect.ValueOfBytes(nil) default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.v1.MsgCreate")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.v1.MsgInit")) } - panic(fmt.Errorf("message cosmos.accounts.v1.MsgCreate does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message cosmos.accounts.v1.MsgInit 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_MsgCreate) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { +func (x *fastReflection_MsgInit) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { switch d.FullName() { default: - panic(fmt.Errorf("%s is not a oneof field in cosmos.accounts.v1.MsgCreate", d.FullName())) + panic(fmt.Errorf("%s is not a oneof field in cosmos.accounts.v1.MsgInit", d.FullName())) } panic("unreachable") } @@ -271,7 +271,7 @@ func (x *fastReflection_MsgCreate) WhichOneof(d protoreflect.OneofDescriptor) pr // 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_MsgCreate) GetUnknown() protoreflect.RawFields { +func (x *fastReflection_MsgInit) GetUnknown() protoreflect.RawFields { return x.unknownFields } @@ -282,7 +282,7 @@ func (x *fastReflection_MsgCreate) GetUnknown() protoreflect.RawFields { // An empty RawFields may be passed to clear the fields. // // SetUnknown is a mutating operation and unsafe for concurrent use. -func (x *fastReflection_MsgCreate) SetUnknown(fields protoreflect.RawFields) { +func (x *fastReflection_MsgInit) SetUnknown(fields protoreflect.RawFields) { x.unknownFields = fields } @@ -294,7 +294,7 @@ func (x *fastReflection_MsgCreate) SetUnknown(fields protoreflect.RawFields) { // message type, but the details are implementation dependent. // Validity is not part of the protobuf data model, and may not // be preserved in marshaling or other operations. -func (x *fastReflection_MsgCreate) IsValid() bool { +func (x *fastReflection_MsgInit) IsValid() bool { return x != nil } @@ -304,9 +304,9 @@ func (x *fastReflection_MsgCreate) IsValid() bool { // The returned methods type is identical to // "google.golang.org/protobuf/runtime/protoiface".Methods. // Consult the protoiface package documentation for details. -func (x *fastReflection_MsgCreate) ProtoMethods() *protoiface.Methods { +func (x *fastReflection_MsgInit) ProtoMethods() *protoiface.Methods { size := func(input protoiface.SizeInput) protoiface.SizeOutput { - x := input.Message.Interface().(*MsgCreate) + x := input.Message.Interface().(*MsgInit) if x == nil { return protoiface.SizeOutput{ NoUnkeyedLiterals: input.NoUnkeyedLiterals, @@ -340,7 +340,7 @@ func (x *fastReflection_MsgCreate) ProtoMethods() *protoiface.Methods { } marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) { - x := input.Message.Interface().(*MsgCreate) + x := input.Message.Interface().(*MsgInit) if x == nil { return protoiface.MarshalOutput{ NoUnkeyedLiterals: input.NoUnkeyedLiterals, @@ -391,7 +391,7 @@ func (x *fastReflection_MsgCreate) ProtoMethods() *protoiface.Methods { }, nil } unmarshal := func(input protoiface.UnmarshalInput) (protoiface.UnmarshalOutput, error) { - x := input.Message.Interface().(*MsgCreate) + x := input.Message.Interface().(*MsgInit) if x == nil { return protoiface.UnmarshalOutput{ NoUnkeyedLiterals: input.NoUnkeyedLiterals, @@ -423,10 +423,10 @@ func (x *fastReflection_MsgCreate) ProtoMethods() *protoiface.Methods { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: MsgCreate: wiretype end group for non-group") + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: MsgInit: wiretype end group for non-group") } if fieldNum <= 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: MsgCreate: illegal tag %d (wire type %d)", fieldNum, wire) + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: MsgInit: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -563,27 +563,27 @@ func (x *fastReflection_MsgCreate) ProtoMethods() *protoiface.Methods { } var ( - md_MsgCreateResponse protoreflect.MessageDescriptor - fd_MsgCreateResponse_account_address protoreflect.FieldDescriptor - fd_MsgCreateResponse_response protoreflect.FieldDescriptor + md_MsgInitResponse protoreflect.MessageDescriptor + fd_MsgInitResponse_account_address protoreflect.FieldDescriptor + fd_MsgInitResponse_response protoreflect.FieldDescriptor ) func init() { file_cosmos_accounts_v1_tx_proto_init() - md_MsgCreateResponse = File_cosmos_accounts_v1_tx_proto.Messages().ByName("MsgCreateResponse") - fd_MsgCreateResponse_account_address = md_MsgCreateResponse.Fields().ByName("account_address") - fd_MsgCreateResponse_response = md_MsgCreateResponse.Fields().ByName("response") + md_MsgInitResponse = File_cosmos_accounts_v1_tx_proto.Messages().ByName("MsgInitResponse") + fd_MsgInitResponse_account_address = md_MsgInitResponse.Fields().ByName("account_address") + fd_MsgInitResponse_response = md_MsgInitResponse.Fields().ByName("response") } -var _ protoreflect.Message = (*fastReflection_MsgCreateResponse)(nil) +var _ protoreflect.Message = (*fastReflection_MsgInitResponse)(nil) -type fastReflection_MsgCreateResponse MsgCreateResponse +type fastReflection_MsgInitResponse MsgInitResponse -func (x *MsgCreateResponse) ProtoReflect() protoreflect.Message { - return (*fastReflection_MsgCreateResponse)(x) +func (x *MsgInitResponse) ProtoReflect() protoreflect.Message { + return (*fastReflection_MsgInitResponse)(x) } -func (x *MsgCreateResponse) slowProtoReflect() protoreflect.Message { +func (x *MsgInitResponse) slowProtoReflect() protoreflect.Message { mi := &file_cosmos_accounts_v1_tx_proto_msgTypes[1] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -595,43 +595,43 @@ func (x *MsgCreateResponse) slowProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -var _fastReflection_MsgCreateResponse_messageType fastReflection_MsgCreateResponse_messageType -var _ protoreflect.MessageType = fastReflection_MsgCreateResponse_messageType{} +var _fastReflection_MsgInitResponse_messageType fastReflection_MsgInitResponse_messageType +var _ protoreflect.MessageType = fastReflection_MsgInitResponse_messageType{} -type fastReflection_MsgCreateResponse_messageType struct{} +type fastReflection_MsgInitResponse_messageType struct{} -func (x fastReflection_MsgCreateResponse_messageType) Zero() protoreflect.Message { - return (*fastReflection_MsgCreateResponse)(nil) +func (x fastReflection_MsgInitResponse_messageType) Zero() protoreflect.Message { + return (*fastReflection_MsgInitResponse)(nil) } -func (x fastReflection_MsgCreateResponse_messageType) New() protoreflect.Message { - return new(fastReflection_MsgCreateResponse) +func (x fastReflection_MsgInitResponse_messageType) New() protoreflect.Message { + return new(fastReflection_MsgInitResponse) } -func (x fastReflection_MsgCreateResponse_messageType) Descriptor() protoreflect.MessageDescriptor { - return md_MsgCreateResponse +func (x fastReflection_MsgInitResponse_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_MsgInitResponse } // Descriptor returns message descriptor, which contains only the protobuf // type information for the message. -func (x *fastReflection_MsgCreateResponse) Descriptor() protoreflect.MessageDescriptor { - return md_MsgCreateResponse +func (x *fastReflection_MsgInitResponse) Descriptor() protoreflect.MessageDescriptor { + return md_MsgInitResponse } // 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_MsgCreateResponse) Type() protoreflect.MessageType { - return _fastReflection_MsgCreateResponse_messageType +func (x *fastReflection_MsgInitResponse) Type() protoreflect.MessageType { + return _fastReflection_MsgInitResponse_messageType } // New returns a newly allocated and mutable empty message. -func (x *fastReflection_MsgCreateResponse) New() protoreflect.Message { - return new(fastReflection_MsgCreateResponse) +func (x *fastReflection_MsgInitResponse) New() protoreflect.Message { + return new(fastReflection_MsgInitResponse) } // Interface unwraps the message reflection interface and // returns the underlying ProtoMessage interface. -func (x *fastReflection_MsgCreateResponse) Interface() protoreflect.ProtoMessage { - return (*MsgCreateResponse)(x) +func (x *fastReflection_MsgInitResponse) Interface() protoreflect.ProtoMessage { + return (*MsgInitResponse)(x) } // Range iterates over every populated field in an undefined order, @@ -639,16 +639,16 @@ func (x *fastReflection_MsgCreateResponse) Interface() protoreflect.ProtoMessage // Range returns immediately if f returns false. // While iterating, mutating operations may only be performed // on the current field descriptor. -func (x *fastReflection_MsgCreateResponse) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { +func (x *fastReflection_MsgInitResponse) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { if x.AccountAddress != "" { value := protoreflect.ValueOfString(x.AccountAddress) - if !f(fd_MsgCreateResponse_account_address, value) { + if !f(fd_MsgInitResponse_account_address, value) { return } } if len(x.Response) != 0 { value := protoreflect.ValueOfBytes(x.Response) - if !f(fd_MsgCreateResponse_response, value) { + if !f(fd_MsgInitResponse_response, value) { return } } @@ -665,17 +665,17 @@ func (x *fastReflection_MsgCreateResponse) Range(f func(protoreflect.FieldDescri // 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_MsgCreateResponse) Has(fd protoreflect.FieldDescriptor) bool { +func (x *fastReflection_MsgInitResponse) Has(fd protoreflect.FieldDescriptor) bool { switch fd.FullName() { - case "cosmos.accounts.v1.MsgCreateResponse.account_address": + case "cosmos.accounts.v1.MsgInitResponse.account_address": return x.AccountAddress != "" - case "cosmos.accounts.v1.MsgCreateResponse.response": + case "cosmos.accounts.v1.MsgInitResponse.response": return len(x.Response) != 0 default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.v1.MsgCreateResponse")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.v1.MsgInitResponse")) } - panic(fmt.Errorf("message cosmos.accounts.v1.MsgCreateResponse does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message cosmos.accounts.v1.MsgInitResponse does not contain field %s", fd.FullName())) } } @@ -685,17 +685,17 @@ func (x *fastReflection_MsgCreateResponse) Has(fd protoreflect.FieldDescriptor) // associated with the given field number. // // Clear is a mutating operation and unsafe for concurrent use. -func (x *fastReflection_MsgCreateResponse) Clear(fd protoreflect.FieldDescriptor) { +func (x *fastReflection_MsgInitResponse) Clear(fd protoreflect.FieldDescriptor) { switch fd.FullName() { - case "cosmos.accounts.v1.MsgCreateResponse.account_address": + case "cosmos.accounts.v1.MsgInitResponse.account_address": x.AccountAddress = "" - case "cosmos.accounts.v1.MsgCreateResponse.response": + case "cosmos.accounts.v1.MsgInitResponse.response": x.Response = nil default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.v1.MsgCreateResponse")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.v1.MsgInitResponse")) } - panic(fmt.Errorf("message cosmos.accounts.v1.MsgCreateResponse does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message cosmos.accounts.v1.MsgInitResponse does not contain field %s", fd.FullName())) } } @@ -705,19 +705,19 @@ func (x *fastReflection_MsgCreateResponse) Clear(fd protoreflect.FieldDescriptor // the default value of a bytes scalar is guaranteed to be a copy. // For unpopulated composite types, it returns an empty, read-only view // of the value; to obtain a mutable reference, use Mutable. -func (x *fastReflection_MsgCreateResponse) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { +func (x *fastReflection_MsgInitResponse) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { switch descriptor.FullName() { - case "cosmos.accounts.v1.MsgCreateResponse.account_address": + case "cosmos.accounts.v1.MsgInitResponse.account_address": value := x.AccountAddress return protoreflect.ValueOfString(value) - case "cosmos.accounts.v1.MsgCreateResponse.response": + case "cosmos.accounts.v1.MsgInitResponse.response": value := x.Response return protoreflect.ValueOfBytes(value) default: if descriptor.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.v1.MsgCreateResponse")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.v1.MsgInitResponse")) } - panic(fmt.Errorf("message cosmos.accounts.v1.MsgCreateResponse does not contain field %s", descriptor.FullName())) + panic(fmt.Errorf("message cosmos.accounts.v1.MsgInitResponse does not contain field %s", descriptor.FullName())) } } @@ -731,17 +731,17 @@ func (x *fastReflection_MsgCreateResponse) Get(descriptor protoreflect.FieldDesc // empty, read-only value, then it panics. // // Set is a mutating operation and unsafe for concurrent use. -func (x *fastReflection_MsgCreateResponse) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { +func (x *fastReflection_MsgInitResponse) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { switch fd.FullName() { - case "cosmos.accounts.v1.MsgCreateResponse.account_address": + case "cosmos.accounts.v1.MsgInitResponse.account_address": x.AccountAddress = value.Interface().(string) - case "cosmos.accounts.v1.MsgCreateResponse.response": + case "cosmos.accounts.v1.MsgInitResponse.response": x.Response = value.Bytes() default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.v1.MsgCreateResponse")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.v1.MsgInitResponse")) } - panic(fmt.Errorf("message cosmos.accounts.v1.MsgCreateResponse does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message cosmos.accounts.v1.MsgInitResponse does not contain field %s", fd.FullName())) } } @@ -755,44 +755,44 @@ func (x *fastReflection_MsgCreateResponse) Set(fd protoreflect.FieldDescriptor, // It panics if the field does not contain a composite type. // // Mutable is a mutating operation and unsafe for concurrent use. -func (x *fastReflection_MsgCreateResponse) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { +func (x *fastReflection_MsgInitResponse) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { switch fd.FullName() { - case "cosmos.accounts.v1.MsgCreateResponse.account_address": - panic(fmt.Errorf("field account_address of message cosmos.accounts.v1.MsgCreateResponse is not mutable")) - case "cosmos.accounts.v1.MsgCreateResponse.response": - panic(fmt.Errorf("field response of message cosmos.accounts.v1.MsgCreateResponse is not mutable")) + case "cosmos.accounts.v1.MsgInitResponse.account_address": + panic(fmt.Errorf("field account_address of message cosmos.accounts.v1.MsgInitResponse is not mutable")) + case "cosmos.accounts.v1.MsgInitResponse.response": + panic(fmt.Errorf("field response of message cosmos.accounts.v1.MsgInitResponse is not mutable")) default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.v1.MsgCreateResponse")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.v1.MsgInitResponse")) } - panic(fmt.Errorf("message cosmos.accounts.v1.MsgCreateResponse does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message cosmos.accounts.v1.MsgInitResponse 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_MsgCreateResponse) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { +func (x *fastReflection_MsgInitResponse) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { switch fd.FullName() { - case "cosmos.accounts.v1.MsgCreateResponse.account_address": + case "cosmos.accounts.v1.MsgInitResponse.account_address": return protoreflect.ValueOfString("") - case "cosmos.accounts.v1.MsgCreateResponse.response": + case "cosmos.accounts.v1.MsgInitResponse.response": return protoreflect.ValueOfBytes(nil) default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.v1.MsgCreateResponse")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.v1.MsgInitResponse")) } - panic(fmt.Errorf("message cosmos.accounts.v1.MsgCreateResponse does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message cosmos.accounts.v1.MsgInitResponse 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_MsgCreateResponse) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { +func (x *fastReflection_MsgInitResponse) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { switch d.FullName() { default: - panic(fmt.Errorf("%s is not a oneof field in cosmos.accounts.v1.MsgCreateResponse", d.FullName())) + panic(fmt.Errorf("%s is not a oneof field in cosmos.accounts.v1.MsgInitResponse", d.FullName())) } panic("unreachable") } @@ -800,7 +800,7 @@ func (x *fastReflection_MsgCreateResponse) WhichOneof(d protoreflect.OneofDescri // 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_MsgCreateResponse) GetUnknown() protoreflect.RawFields { +func (x *fastReflection_MsgInitResponse) GetUnknown() protoreflect.RawFields { return x.unknownFields } @@ -811,7 +811,7 @@ func (x *fastReflection_MsgCreateResponse) GetUnknown() protoreflect.RawFields { // An empty RawFields may be passed to clear the fields. // // SetUnknown is a mutating operation and unsafe for concurrent use. -func (x *fastReflection_MsgCreateResponse) SetUnknown(fields protoreflect.RawFields) { +func (x *fastReflection_MsgInitResponse) SetUnknown(fields protoreflect.RawFields) { x.unknownFields = fields } @@ -823,7 +823,7 @@ func (x *fastReflection_MsgCreateResponse) SetUnknown(fields protoreflect.RawFie // 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_MsgCreateResponse) IsValid() bool { +func (x *fastReflection_MsgInitResponse) IsValid() bool { return x != nil } @@ -833,9 +833,9 @@ func (x *fastReflection_MsgCreateResponse) IsValid() bool { // The returned methods type is identical to // "google.golang.org/protobuf/runtime/protoiface".Methods. // Consult the protoiface package documentation for details. -func (x *fastReflection_MsgCreateResponse) ProtoMethods() *protoiface.Methods { +func (x *fastReflection_MsgInitResponse) ProtoMethods() *protoiface.Methods { size := func(input protoiface.SizeInput) protoiface.SizeOutput { - x := input.Message.Interface().(*MsgCreateResponse) + x := input.Message.Interface().(*MsgInitResponse) if x == nil { return protoiface.SizeOutput{ NoUnkeyedLiterals: input.NoUnkeyedLiterals, @@ -865,7 +865,7 @@ func (x *fastReflection_MsgCreateResponse) ProtoMethods() *protoiface.Methods { } marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) { - x := input.Message.Interface().(*MsgCreateResponse) + x := input.Message.Interface().(*MsgInitResponse) if x == nil { return protoiface.MarshalOutput{ NoUnkeyedLiterals: input.NoUnkeyedLiterals, @@ -909,7 +909,7 @@ func (x *fastReflection_MsgCreateResponse) ProtoMethods() *protoiface.Methods { }, nil } unmarshal := func(input protoiface.UnmarshalInput) (protoiface.UnmarshalOutput, error) { - x := input.Message.Interface().(*MsgCreateResponse) + x := input.Message.Interface().(*MsgInitResponse) if x == nil { return protoiface.UnmarshalOutput{ NoUnkeyedLiterals: input.NoUnkeyedLiterals, @@ -941,10 +941,10 @@ func (x *fastReflection_MsgCreateResponse) ProtoMethods() *protoiface.Methods { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: MsgCreateResponse: wiretype end group for non-group") + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: MsgInitResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: MsgCreateResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: MsgInitResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -2033,8 +2033,8 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) -// MsgCreate defines the Create request type for the Msg/Create RPC method. -type MsgCreate struct { +// MsgInit defines the Create request type for the Msg/Create RPC method. +type MsgInit struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields @@ -2049,8 +2049,8 @@ type MsgCreate struct { Message []byte `protobuf:"bytes,3,opt,name=message,proto3" json:"message,omitempty"` } -func (x *MsgCreate) Reset() { - *x = MsgCreate{} +func (x *MsgInit) Reset() { + *x = MsgInit{} if protoimpl.UnsafeEnabled { mi := &file_cosmos_accounts_v1_tx_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -2058,40 +2058,40 @@ func (x *MsgCreate) Reset() { } } -func (x *MsgCreate) String() string { +func (x *MsgInit) String() string { return protoimpl.X.MessageStringOf(x) } -func (*MsgCreate) ProtoMessage() {} +func (*MsgInit) ProtoMessage() {} -// Deprecated: Use MsgCreate.ProtoReflect.Descriptor instead. -func (*MsgCreate) Descriptor() ([]byte, []int) { +// Deprecated: Use MsgInit.ProtoReflect.Descriptor instead. +func (*MsgInit) Descriptor() ([]byte, []int) { return file_cosmos_accounts_v1_tx_proto_rawDescGZIP(), []int{0} } -func (x *MsgCreate) GetSender() string { +func (x *MsgInit) GetSender() string { if x != nil { return x.Sender } return "" } -func (x *MsgCreate) GetAccountType() string { +func (x *MsgInit) GetAccountType() string { if x != nil { return x.AccountType } return "" } -func (x *MsgCreate) GetMessage() []byte { +func (x *MsgInit) GetMessage() []byte { if x != nil { return x.Message } return nil } -// MsgCreateResponse defines the Create response type for the Msg/Create RPC method. -type MsgCreateResponse struct { +// MsgInitResponse defines the Create response type for the Msg/Create RPC method. +type MsgInitResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields @@ -2102,8 +2102,8 @@ type MsgCreateResponse struct { Response []byte `protobuf:"bytes,2,opt,name=response,proto3" json:"response,omitempty"` } -func (x *MsgCreateResponse) Reset() { - *x = MsgCreateResponse{} +func (x *MsgInitResponse) Reset() { + *x = MsgInitResponse{} if protoimpl.UnsafeEnabled { mi := &file_cosmos_accounts_v1_tx_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -2111,25 +2111,25 @@ func (x *MsgCreateResponse) Reset() { } } -func (x *MsgCreateResponse) String() string { +func (x *MsgInitResponse) String() string { return protoimpl.X.MessageStringOf(x) } -func (*MsgCreateResponse) ProtoMessage() {} +func (*MsgInitResponse) ProtoMessage() {} -// Deprecated: Use MsgCreateResponse.ProtoReflect.Descriptor instead. -func (*MsgCreateResponse) Descriptor() ([]byte, []int) { +// Deprecated: Use MsgInitResponse.ProtoReflect.Descriptor instead. +func (*MsgInitResponse) Descriptor() ([]byte, []int) { return file_cosmos_accounts_v1_tx_proto_rawDescGZIP(), []int{1} } -func (x *MsgCreateResponse) GetAccountAddress() string { +func (x *MsgInitResponse) GetAccountAddress() string { if x != nil { return x.AccountAddress } return "" } -func (x *MsgCreateResponse) GetResponse() []byte { +func (x *MsgInitResponse) GetResponse() []byte { if x != nil { return x.Response } @@ -2234,50 +2234,49 @@ var file_cosmos_accounts_v1_tx_proto_rawDesc = []byte{ 0x0a, 0x1b, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2f, 0x76, 0x31, 0x2f, 0x74, 0x78, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x12, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2e, 0x76, - 0x31, 0x22, 0x60, 0x0a, 0x09, 0x4d, 0x73, 0x67, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x12, 0x16, - 0x0a, 0x06, 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, - 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x12, 0x21, 0x0a, 0x0c, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, - 0x74, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x61, 0x63, - 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, - 0x73, 0x61, 0x67, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, - 0x61, 0x67, 0x65, 0x22, 0x58, 0x0a, 0x11, 0x4d, 0x73, 0x67, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x27, 0x0a, 0x0f, 0x61, 0x63, 0x63, 0x6f, - 0x75, 0x6e, 0x74, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x0e, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, - 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x0c, 0x52, 0x08, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x56, 0x0a, - 0x0a, 0x4d, 0x73, 0x67, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x73, - 0x65, 0x6e, 0x64, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x65, 0x6e, - 0x64, 0x65, 0x72, 0x12, 0x16, 0x0a, 0x06, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x06, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x6d, - 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x6d, 0x65, - 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x30, 0x0a, 0x12, 0x4d, 0x73, 0x67, 0x45, 0x78, 0x65, 0x63, - 0x75, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x72, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x08, 0x72, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0xa8, 0x01, 0x0a, 0x03, 0x4d, 0x73, 0x67, 0x12, - 0x4e, 0x0a, 0x06, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x12, 0x1d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, - 0x6f, 0x73, 0x2e, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x4d, - 0x73, 0x67, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x1a, 0x25, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, - 0x73, 0x2e, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x73, - 0x67, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, - 0x51, 0x0a, 0x07, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x65, 0x12, 0x1e, 0x2e, 0x63, 0x6f, 0x73, - 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2e, 0x76, 0x31, 0x2e, - 0x4d, 0x73, 0x67, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x65, 0x1a, 0x26, 0x2e, 0x63, 0x6f, 0x73, - 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2e, 0x76, 0x31, 0x2e, - 0x4d, 0x73, 0x67, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x42, 0xbb, 0x01, 0x0a, 0x16, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, - 0x73, 0x2e, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2e, 0x76, 0x31, 0x42, 0x07, 0x54, - 0x78, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x2e, 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, 0x76, 0x31, 0x3b, 0x61, 0x63, - 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x41, 0x58, 0xaa, 0x02, - 0x12, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, - 0x2e, 0x56, 0x31, 0xca, 0x02, 0x12, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x41, 0x63, 0x63, - 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x1e, 0x43, 0x6f, 0x73, 0x6d, 0x6f, - 0x73, 0x5c, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, - 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x14, 0x43, 0x6f, 0x73, 0x6d, - 0x6f, 0x73, 0x3a, 0x3a, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x3a, 0x3a, 0x56, 0x31, - 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x31, 0x22, 0x5e, 0x0a, 0x07, 0x4d, 0x73, 0x67, 0x49, 0x6e, 0x69, 0x74, 0x12, 0x16, 0x0a, 0x06, + 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x65, + 0x6e, 0x64, 0x65, 0x72, 0x12, 0x21, 0x0a, 0x0c, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x5f, + 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x61, 0x63, 0x63, 0x6f, + 0x75, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, + 0x67, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, + 0x65, 0x22, 0x56, 0x0a, 0x0f, 0x4d, 0x73, 0x67, 0x49, 0x6e, 0x69, 0x74, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x27, 0x0a, 0x0f, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x5f, + 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x61, + 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x1a, 0x0a, + 0x08, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, + 0x08, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x56, 0x0a, 0x0a, 0x4d, 0x73, 0x67, + 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x65, 0x6e, 0x64, 0x65, + 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x12, + 0x16, 0x0a, 0x06, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x06, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, + 0x67, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, + 0x65, 0x22, 0x30, 0x0a, 0x12, 0x4d, 0x73, 0x67, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x65, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x08, 0x72, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x32, 0xa2, 0x01, 0x0a, 0x03, 0x4d, 0x73, 0x67, 0x12, 0x48, 0x0a, 0x04, 0x49, + 0x6e, 0x69, 0x74, 0x12, 0x1b, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x63, 0x63, + 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x49, 0x6e, 0x69, 0x74, + 0x1a, 0x23, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, + 0x74, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x49, 0x6e, 0x69, 0x74, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x51, 0x0a, 0x07, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x65, + 0x12, 0x1e, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, + 0x74, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x65, + 0x1a, 0x26, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, + 0x74, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x65, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0xbb, 0x01, 0x0a, 0x16, 0x63, 0x6f, 0x6d, + 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, + 0x2e, 0x76, 0x31, 0x42, 0x07, 0x54, 0x78, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x2e, + 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, 0x76, 0x31, 0x3b, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x76, 0x31, 0xa2, 0x02, + 0x03, 0x43, 0x41, 0x58, 0xaa, 0x02, 0x12, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x63, + 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x12, 0x43, 0x6f, 0x73, 0x6d, + 0x6f, 0x73, 0x5c, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x5c, 0x56, 0x31, 0xe2, 0x02, + 0x1e, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, + 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, + 0x02, 0x14, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x3a, 0x3a, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, + 0x74, 0x73, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -2294,15 +2293,15 @@ func file_cosmos_accounts_v1_tx_proto_rawDescGZIP() []byte { var file_cosmos_accounts_v1_tx_proto_msgTypes = make([]protoimpl.MessageInfo, 4) var file_cosmos_accounts_v1_tx_proto_goTypes = []interface{}{ - (*MsgCreate)(nil), // 0: cosmos.accounts.v1.MsgCreate - (*MsgCreateResponse)(nil), // 1: cosmos.accounts.v1.MsgCreateResponse + (*MsgInit)(nil), // 0: cosmos.accounts.v1.MsgInit + (*MsgInitResponse)(nil), // 1: cosmos.accounts.v1.MsgInitResponse (*MsgExecute)(nil), // 2: cosmos.accounts.v1.MsgExecute (*MsgExecuteResponse)(nil), // 3: cosmos.accounts.v1.MsgExecuteResponse } var file_cosmos_accounts_v1_tx_proto_depIdxs = []int32{ - 0, // 0: cosmos.accounts.v1.Msg.Create:input_type -> cosmos.accounts.v1.MsgCreate + 0, // 0: cosmos.accounts.v1.Msg.Init:input_type -> cosmos.accounts.v1.MsgInit 2, // 1: cosmos.accounts.v1.Msg.Execute:input_type -> cosmos.accounts.v1.MsgExecute - 1, // 2: cosmos.accounts.v1.Msg.Create:output_type -> cosmos.accounts.v1.MsgCreateResponse + 1, // 2: cosmos.accounts.v1.Msg.Init:output_type -> cosmos.accounts.v1.MsgInitResponse 3, // 3: cosmos.accounts.v1.Msg.Execute:output_type -> cosmos.accounts.v1.MsgExecuteResponse 2, // [2:4] is the sub-list for method output_type 0, // [0:2] is the sub-list for method input_type @@ -2318,7 +2317,7 @@ func file_cosmos_accounts_v1_tx_proto_init() { } if !protoimpl.UnsafeEnabled { file_cosmos_accounts_v1_tx_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*MsgCreate); i { + switch v := v.(*MsgInit); i { case 0: return &v.state case 1: @@ -2330,7 +2329,7 @@ func file_cosmos_accounts_v1_tx_proto_init() { } } file_cosmos_accounts_v1_tx_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*MsgCreateResponse); i { + switch v := v.(*MsgInitResponse); i { case 0: return &v.state case 1: diff --git a/api/cosmos/accounts/v1/tx_grpc.pb.go b/api/cosmos/accounts/v1/tx_grpc.pb.go index ccf2410ed165..553510dfa123 100644 --- a/api/cosmos/accounts/v1/tx_grpc.pb.go +++ b/api/cosmos/accounts/v1/tx_grpc.pb.go @@ -19,7 +19,7 @@ import ( const _ = grpc.SupportPackageIsVersion7 const ( - Msg_Create_FullMethodName = "/cosmos.accounts.v1.Msg/Create" + Msg_Init_FullMethodName = "/cosmos.accounts.v1.Msg/Init" Msg_Execute_FullMethodName = "/cosmos.accounts.v1.Msg/Execute" ) @@ -27,8 +27,8 @@ const ( // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. type MsgClient interface { - // Create creates a new account in the chain. - Create(ctx context.Context, in *MsgCreate, opts ...grpc.CallOption) (*MsgCreateResponse, error) + // Init creates a new account in the chain. + Init(ctx context.Context, in *MsgInit, opts ...grpc.CallOption) (*MsgInitResponse, error) // Execute executes a message to the target account. Execute(ctx context.Context, in *MsgExecute, opts ...grpc.CallOption) (*MsgExecuteResponse, error) } @@ -41,9 +41,9 @@ func NewMsgClient(cc grpc.ClientConnInterface) MsgClient { return &msgClient{cc} } -func (c *msgClient) Create(ctx context.Context, in *MsgCreate, opts ...grpc.CallOption) (*MsgCreateResponse, error) { - out := new(MsgCreateResponse) - err := c.cc.Invoke(ctx, Msg_Create_FullMethodName, in, out, opts...) +func (c *msgClient) Init(ctx context.Context, in *MsgInit, opts ...grpc.CallOption) (*MsgInitResponse, error) { + out := new(MsgInitResponse) + err := c.cc.Invoke(ctx, Msg_Init_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -63,8 +63,8 @@ func (c *msgClient) Execute(ctx context.Context, in *MsgExecute, opts ...grpc.Ca // All implementations must embed UnimplementedMsgServer // for forward compatibility type MsgServer interface { - // Create creates a new account in the chain. - Create(context.Context, *MsgCreate) (*MsgCreateResponse, error) + // Init creates a new account in the chain. + Init(context.Context, *MsgInit) (*MsgInitResponse, error) // Execute executes a message to the target account. Execute(context.Context, *MsgExecute) (*MsgExecuteResponse, error) mustEmbedUnimplementedMsgServer() @@ -74,8 +74,8 @@ type MsgServer interface { type UnimplementedMsgServer struct { } -func (UnimplementedMsgServer) Create(context.Context, *MsgCreate) (*MsgCreateResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Create not implemented") +func (UnimplementedMsgServer) Init(context.Context, *MsgInit) (*MsgInitResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Init not implemented") } func (UnimplementedMsgServer) Execute(context.Context, *MsgExecute) (*MsgExecuteResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Execute not implemented") @@ -93,20 +93,20 @@ func RegisterMsgServer(s grpc.ServiceRegistrar, srv MsgServer) { s.RegisterService(&Msg_ServiceDesc, srv) } -func _Msg_Create_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgCreate) +func _Msg_Init_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgInit) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(MsgServer).Create(ctx, in) + return srv.(MsgServer).Init(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: Msg_Create_FullMethodName, + FullMethod: Msg_Init_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).Create(ctx, req.(*MsgCreate)) + return srv.(MsgServer).Init(ctx, req.(*MsgInit)) } return interceptor(ctx, in, info, handler) } @@ -137,8 +137,8 @@ var Msg_ServiceDesc = grpc.ServiceDesc{ HandlerType: (*MsgServer)(nil), Methods: []grpc.MethodDesc{ { - MethodName: "Create", - Handler: _Msg_Create_Handler, + MethodName: "Init", + Handler: _Msg_Init_Handler, }, { MethodName: "Execute", diff --git a/proto/cosmos/accounts/v1/tx.proto b/proto/cosmos/accounts/v1/tx.proto index 4446c4c4746e..e12667ac0596 100644 --- a/proto/cosmos/accounts/v1/tx.proto +++ b/proto/cosmos/accounts/v1/tx.proto @@ -6,15 +6,15 @@ option go_package = "cosmossdk.io/x/accounts/v1"; // Msg defines the Msg service for the x/accounts module. service Msg { - // 'Create' creates a new account in the chain. - rpc Create(MsgCreate) returns (MsgCreateResponse); + // Init creates a new account in the chain. + rpc Init(MsgInit) returns (MsgInitResponse); - // `Execute` executes a message to the target account. + // Execute executes a message to the target account. rpc Execute(MsgExecute) returns (MsgExecuteResponse); } -// MsgCreate defines the Create request type for the Msg/Create RPC method. -message MsgCreate { +// MsgInit defines the Create request type for the Msg/Create RPC method. +message MsgInit { // sender is the address of the sender of this message. string sender = 1; // account_type is the type of the account to be created. @@ -25,8 +25,8 @@ message MsgCreate { bytes message = 3; } -// MsgCreateResponse defines the Create response type for the Msg/Create RPC method. -message MsgCreateResponse { +// MsgInitResponse defines the Create response type for the Msg/Create RPC method. +message MsgInitResponse { // account_address is the address of the newly created account. string account_address = 1; // response is the response returned by the account implementation. diff --git a/x/accounts/keeper.go b/x/accounts/keeper.go index d95894ee8cd8..0da45b6f7d8c 100644 --- a/x/accounts/keeper.go +++ b/x/accounts/keeper.go @@ -63,8 +63,8 @@ type Keeper struct { AccountsByType collections.Map[[]byte, string] } -// Create creates a new account of the given type. -func (k Keeper) Create( +// Init creates a new account of the given type. +func (k Keeper) Init( ctx context.Context, accountType string, creator []byte, diff --git a/x/accounts/keeper_test.go b/x/accounts/keeper_test.go index e8c68aca2356..a1c0fe6a0a00 100644 --- a/x/accounts/keeper_test.go +++ b/x/accounts/keeper_test.go @@ -36,7 +36,7 @@ func TestKeeper_Create(t *testing.T) { t.Run("ok", func(t *testing.T) { sender := []byte("sender") - resp, addr, err := m.Create(ctx, "test", sender, &emptypb.Empty{}) + resp, addr, err := m.Init(ctx, "test", sender, &emptypb.Empty{}) require.NoError(t, err) require.Equal(t, &emptypb.Empty{}, resp) require.NotNil(t, addr) @@ -53,7 +53,7 @@ func TestKeeper_Create(t *testing.T) { }) t.Run("unknown account type", func(t *testing.T) { - _, _, err := m.Create(ctx, "unknown", []byte("sender"), &emptypb.Empty{}) + _, _, err := m.Init(ctx, "unknown", []byte("sender"), &emptypb.Empty{}) require.ErrorIs(t, err, errAccountTypeNotFound) }) } @@ -65,7 +65,7 @@ func TestKeeper_Execute(t *testing.T) { // create account sender := []byte("sender") - _, accAddr, err := m.Create(ctx, "test", sender, &emptypb.Empty{}) + _, accAddr, err := m.Init(ctx, "test", sender, &emptypb.Empty{}) require.NoError(t, err) t.Run("ok", func(t *testing.T) { @@ -87,7 +87,7 @@ func TestKeeper_Query(t *testing.T) { // create account sender := []byte("sender") - _, accAddr, err := m.Create(ctx, "test", sender, &emptypb.Empty{}) + _, accAddr, err := m.Init(ctx, "test", sender, &emptypb.Empty{}) require.NoError(t, err) t.Run("ok", func(t *testing.T) { diff --git a/x/accounts/msg_server.go b/x/accounts/msg_server.go index 2abd9a89c134..8e682bb89529 100644 --- a/x/accounts/msg_server.go +++ b/x/accounts/msg_server.go @@ -16,7 +16,7 @@ type msgServer struct { k Keeper } -func (m msgServer) Create(ctx context.Context, request *v1.MsgCreate) (*v1.MsgCreateResponse, error) { +func (m msgServer) Init(ctx context.Context, request *v1.MsgInit) (*v1.MsgInitResponse, error) { creator, err := m.k.addressCodec.StringToBytes(request.Sender) if err != nil { return nil, err @@ -34,7 +34,7 @@ func (m msgServer) Create(ctx context.Context, request *v1.MsgCreate) (*v1.MsgCr } // run account creation logic - resp, accAddr, err := m.k.Create(ctx, request.AccountType, creator, msg) + resp, accAddr, err := m.k.Init(ctx, request.AccountType, creator, msg) if err != nil { return nil, err } @@ -51,7 +51,7 @@ func (m msgServer) Create(ctx context.Context, request *v1.MsgCreate) (*v1.MsgCr return nil, err } - return &v1.MsgCreateResponse{ + return &v1.MsgInitResponse{ AccountAddress: accAddrString, Response: respBytes, }, nil diff --git a/x/accounts/msg_server_test.go b/x/accounts/msg_server_test.go index 1a1b0667ceb0..579d8c19a7c3 100644 --- a/x/accounts/msg_server_test.go +++ b/x/accounts/msg_server_test.go @@ -24,7 +24,7 @@ func TestMsgServer(t *testing.T) { initMsg, err := proto.Marshal(&emptypb.Empty{}) require.NoError(t, err) - initResp, err := s.Create(ctx, &v1.MsgCreate{ + initResp, err := s.Init(ctx, &v1.MsgInit{ Sender: "sender", AccountType: "test", Message: initMsg, diff --git a/x/accounts/query_server_test.go b/x/accounts/query_server_test.go index a04570f6abee..3acaecd0dd63 100644 --- a/x/accounts/query_server_test.go +++ b/x/accounts/query_server_test.go @@ -25,7 +25,7 @@ func TestQueryServer(t *testing.T) { initMsg, err := proto.Marshal(&emptypb.Empty{}) require.NoError(t, err) - initResp, err := ms.Create(ctx, &v1.MsgCreate{ + initResp, err := ms.Init(ctx, &v1.MsgInit{ Sender: "sender", AccountType: "test", Message: initMsg, diff --git a/x/accounts/v1/tx.pb.go b/x/accounts/v1/tx.pb.go index e0402635b22f..08006d565876 100644 --- a/x/accounts/v1/tx.pb.go +++ b/x/accounts/v1/tx.pb.go @@ -27,8 +27,8 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// MsgCreate defines the Create request type for the Msg/Create RPC method. -type MsgCreate struct { +// MsgInit defines the Create request type for the Msg/Create RPC method. +type MsgInit struct { // sender is the address of the sender of this message. Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` // account_type is the type of the account to be created. @@ -39,18 +39,18 @@ type MsgCreate struct { Message []byte `protobuf:"bytes,3,opt,name=message,proto3" json:"message,omitempty"` } -func (m *MsgCreate) Reset() { *m = MsgCreate{} } -func (m *MsgCreate) String() string { return proto.CompactTextString(m) } -func (*MsgCreate) ProtoMessage() {} -func (*MsgCreate) Descriptor() ([]byte, []int) { +func (m *MsgInit) Reset() { *m = MsgInit{} } +func (m *MsgInit) String() string { return proto.CompactTextString(m) } +func (*MsgInit) ProtoMessage() {} +func (*MsgInit) Descriptor() ([]byte, []int) { return fileDescriptor_29c2b6d8a13d4189, []int{0} } -func (m *MsgCreate) XXX_Unmarshal(b []byte) error { +func (m *MsgInit) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgCreate) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgInit) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgCreate.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgInit.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -60,59 +60,59 @@ func (m *MsgCreate) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { return b[:n], nil } } -func (m *MsgCreate) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgCreate.Merge(m, src) +func (m *MsgInit) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgInit.Merge(m, src) } -func (m *MsgCreate) XXX_Size() int { +func (m *MsgInit) XXX_Size() int { return m.Size() } -func (m *MsgCreate) XXX_DiscardUnknown() { - xxx_messageInfo_MsgCreate.DiscardUnknown(m) +func (m *MsgInit) XXX_DiscardUnknown() { + xxx_messageInfo_MsgInit.DiscardUnknown(m) } -var xxx_messageInfo_MsgCreate proto.InternalMessageInfo +var xxx_messageInfo_MsgInit proto.InternalMessageInfo -func (m *MsgCreate) GetSender() string { +func (m *MsgInit) GetSender() string { if m != nil { return m.Sender } return "" } -func (m *MsgCreate) GetAccountType() string { +func (m *MsgInit) GetAccountType() string { if m != nil { return m.AccountType } return "" } -func (m *MsgCreate) GetMessage() []byte { +func (m *MsgInit) GetMessage() []byte { if m != nil { return m.Message } return nil } -// MsgCreateResponse defines the Create response type for the Msg/Create RPC method. -type MsgCreateResponse struct { +// MsgInitResponse defines the Create response type for the Msg/Create RPC method. +type MsgInitResponse struct { // account_address is the address of the newly created account. AccountAddress string `protobuf:"bytes,1,opt,name=account_address,json=accountAddress,proto3" json:"account_address,omitempty"` // response is the response returned by the account implementation. Response []byte `protobuf:"bytes,2,opt,name=response,proto3" json:"response,omitempty"` } -func (m *MsgCreateResponse) Reset() { *m = MsgCreateResponse{} } -func (m *MsgCreateResponse) String() string { return proto.CompactTextString(m) } -func (*MsgCreateResponse) ProtoMessage() {} -func (*MsgCreateResponse) Descriptor() ([]byte, []int) { +func (m *MsgInitResponse) Reset() { *m = MsgInitResponse{} } +func (m *MsgInitResponse) String() string { return proto.CompactTextString(m) } +func (*MsgInitResponse) ProtoMessage() {} +func (*MsgInitResponse) Descriptor() ([]byte, []int) { return fileDescriptor_29c2b6d8a13d4189, []int{1} } -func (m *MsgCreateResponse) XXX_Unmarshal(b []byte) error { +func (m *MsgInitResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgCreateResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgInitResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgCreateResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgInitResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -122,26 +122,26 @@ func (m *MsgCreateResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, e return b[:n], nil } } -func (m *MsgCreateResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgCreateResponse.Merge(m, src) +func (m *MsgInitResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgInitResponse.Merge(m, src) } -func (m *MsgCreateResponse) XXX_Size() int { +func (m *MsgInitResponse) XXX_Size() int { return m.Size() } -func (m *MsgCreateResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgCreateResponse.DiscardUnknown(m) +func (m *MsgInitResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgInitResponse.DiscardUnknown(m) } -var xxx_messageInfo_MsgCreateResponse proto.InternalMessageInfo +var xxx_messageInfo_MsgInitResponse proto.InternalMessageInfo -func (m *MsgCreateResponse) GetAccountAddress() string { +func (m *MsgInitResponse) GetAccountAddress() string { if m != nil { return m.AccountAddress } return "" } -func (m *MsgCreateResponse) GetResponse() []byte { +func (m *MsgInitResponse) GetResponse() []byte { if m != nil { return m.Response } @@ -259,8 +259,8 @@ func (m *MsgExecuteResponse) GetResponse() []byte { } func init() { - proto.RegisterType((*MsgCreate)(nil), "cosmos.accounts.v1.MsgCreate") - proto.RegisterType((*MsgCreateResponse)(nil), "cosmos.accounts.v1.MsgCreateResponse") + proto.RegisterType((*MsgInit)(nil), "cosmos.accounts.v1.MsgInit") + proto.RegisterType((*MsgInitResponse)(nil), "cosmos.accounts.v1.MsgInitResponse") proto.RegisterType((*MsgExecute)(nil), "cosmos.accounts.v1.MsgExecute") proto.RegisterType((*MsgExecuteResponse)(nil), "cosmos.accounts.v1.MsgExecuteResponse") } @@ -268,27 +268,27 @@ func init() { func init() { proto.RegisterFile("cosmos/accounts/v1/tx.proto", fileDescriptor_29c2b6d8a13d4189) } var fileDescriptor_29c2b6d8a13d4189 = []byte{ - // 316 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x92, 0xc1, 0x4a, 0xf3, 0x40, - 0x14, 0x85, 0x3b, 0x7f, 0x21, 0xfd, 0x7b, 0x2d, 0x8a, 0xb3, 0x28, 0x21, 0xe2, 0x50, 0x0b, 0x6a, - 0x57, 0x13, 0xab, 0xbe, 0x80, 0x8a, 0xcb, 0x0a, 0x06, 0x11, 0x71, 0xa3, 0x31, 0xb9, 0x04, 0x91, - 0x76, 0xc2, 0xdc, 0x69, 0x69, 0xdf, 0xc2, 0xc7, 0xf0, 0x51, 0x5c, 0x76, 0xe9, 0x52, 0x9a, 0x17, - 0x11, 0x92, 0x49, 0xac, 0x88, 0x59, 0x9e, 0x7b, 0xb8, 0xe7, 0x7c, 0x73, 0x19, 0xd8, 0x89, 0x14, - 0x8d, 0x15, 0xf9, 0x61, 0x14, 0xa9, 0xe9, 0xc4, 0x90, 0x3f, 0x1b, 0xfa, 0x66, 0x2e, 0x53, 0xad, - 0x8c, 0xe2, 0xbc, 0x30, 0x65, 0x69, 0xca, 0xd9, 0xb0, 0xff, 0x08, 0xed, 0x11, 0x25, 0x17, 0x1a, - 0x43, 0x83, 0xbc, 0x0b, 0x0e, 0xe1, 0x24, 0x46, 0xed, 0xb2, 0x1e, 0x1b, 0xb4, 0x03, 0xab, 0xf8, - 0x1e, 0x74, 0xec, 0xce, 0x83, 0x59, 0xa4, 0xe8, 0xfe, 0xcb, 0xdd, 0x0d, 0x3b, 0xbb, 0x59, 0xa4, - 0xc8, 0x5d, 0x68, 0x8d, 0x91, 0x28, 0x4c, 0xd0, 0x6d, 0xf6, 0xd8, 0xa0, 0x13, 0x94, 0xb2, 0x7f, - 0x07, 0xdb, 0x55, 0x43, 0x80, 0x94, 0xaa, 0x09, 0x21, 0x3f, 0x84, 0xad, 0x32, 0x31, 0x8c, 0x63, - 0x8d, 0x44, 0xb6, 0x72, 0xd3, 0x8e, 0xcf, 0x8a, 0x29, 0xf7, 0xe0, 0xbf, 0xb6, 0x4b, 0x79, 0x6d, - 0x27, 0xa8, 0x74, 0xff, 0x16, 0x60, 0x44, 0xc9, 0xe5, 0x1c, 0xa3, 0x69, 0x0d, 0x7c, 0x17, 0x1c, - 0x13, 0xea, 0x04, 0x8d, 0xc5, 0xb6, 0xaa, 0x86, 0xf8, 0x08, 0xf8, 0x77, 0x6e, 0x85, 0xbc, 0x4e, - 0xc2, 0x7e, 0x92, 0x1c, 0xbf, 0x31, 0x68, 0x8e, 0x28, 0xe1, 0x57, 0xe0, 0xd8, 0x53, 0xee, 0xca, - 0xdf, 0xc7, 0x96, 0xd5, 0x1d, 0xbc, 0xfd, 0x5a, 0xbb, 0xea, 0xbc, 0x86, 0x56, 0xf9, 0x3c, 0xf1, - 0xc7, 0x86, 0xf5, 0xbd, 0x83, 0x7a, 0xbf, 0x8c, 0x3c, 0x3f, 0x7d, 0x5f, 0x09, 0xb6, 0x5c, 0x09, - 0xf6, 0xb9, 0x12, 0xec, 0x35, 0x13, 0x8d, 0x65, 0x26, 0x1a, 0x1f, 0x99, 0x68, 0xdc, 0x7b, 0x45, - 0x00, 0xc5, 0x2f, 0xf2, 0x59, 0xf9, 0xf3, 0xf5, 0x3f, 0xf4, 0xe4, 0xe4, 0x3f, 0xe8, 0xe4, 0x2b, - 0x00, 0x00, 0xff, 0xff, 0x51, 0x1c, 0xbf, 0x06, 0x60, 0x02, 0x00, 0x00, + // 319 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x92, 0xc1, 0x4a, 0xfb, 0x40, + 0x10, 0xc6, 0xbb, 0xff, 0xfe, 0x69, 0x75, 0x2c, 0x16, 0xf6, 0x50, 0x42, 0x0a, 0x4b, 0xad, 0xa0, + 0x3d, 0x6d, 0xac, 0xfa, 0x02, 0x0a, 0x82, 0x1e, 0x7a, 0x30, 0x48, 0x0f, 0x1e, 0x94, 0x98, 0x0c, + 0xa1, 0x48, 0xb3, 0x21, 0xb3, 0x2d, 0xed, 0x5b, 0xf8, 0x0c, 0x3e, 0x8d, 0xc7, 0x1e, 0x3d, 0x4a, + 0xf2, 0x22, 0x42, 0xb2, 0x89, 0x15, 0x69, 0x8e, 0xdf, 0x7c, 0x3b, 0xdf, 0xfc, 0x76, 0x18, 0xe8, + 0xfb, 0x8a, 0xe6, 0x8a, 0x1c, 0xcf, 0xf7, 0xd5, 0x22, 0xd2, 0xe4, 0x2c, 0xc7, 0x8e, 0x5e, 0xc9, + 0x38, 0x51, 0x5a, 0x71, 0x5e, 0x98, 0xb2, 0x34, 0xe5, 0x72, 0x3c, 0x7c, 0x82, 0xf6, 0x84, 0xc2, + 0xbb, 0x68, 0xa6, 0x79, 0x0f, 0x5a, 0x84, 0x51, 0x80, 0x89, 0xc5, 0x06, 0x6c, 0xb4, 0xef, 0x1a, + 0xc5, 0x8f, 0xa0, 0x63, 0x3a, 0x9e, 0xf5, 0x3a, 0x46, 0xeb, 0x5f, 0xee, 0x1e, 0x98, 0xda, 0xc3, + 0x3a, 0x46, 0x6e, 0x41, 0x7b, 0x8e, 0x44, 0x5e, 0x88, 0x56, 0x73, 0xc0, 0x46, 0x1d, 0xb7, 0x94, + 0xc3, 0x29, 0x74, 0x4d, 0xbe, 0x8b, 0x14, 0xab, 0x88, 0x90, 0x9f, 0x42, 0xb7, 0xcc, 0xf3, 0x82, + 0x20, 0x41, 0x22, 0x33, 0xf0, 0xd0, 0x94, 0xaf, 0x8a, 0x2a, 0xb7, 0x61, 0x2f, 0x31, 0x4d, 0xf9, + 0xd0, 0x8e, 0x5b, 0xe9, 0xe1, 0x14, 0x60, 0x42, 0xe1, 0xcd, 0x0a, 0xfd, 0x85, 0xc6, 0x9d, 0xe8, + 0x3d, 0x68, 0x69, 0x2f, 0x09, 0x51, 0x1b, 0x68, 0xa3, 0x6a, 0x78, 0xcf, 0x80, 0xff, 0xe4, 0x56, + 0xc8, 0xdb, 0x24, 0xec, 0x37, 0xc9, 0xf9, 0x3b, 0x83, 0xe6, 0x84, 0x42, 0x7e, 0x0b, 0xff, 0xf3, + 0x35, 0xf6, 0xe5, 0xdf, 0x35, 0x4b, 0xb3, 0x03, 0xfb, 0xb8, 0xc6, 0xac, 0xa6, 0xdd, 0x43, 0xbb, + 0xfc, 0x98, 0xd8, 0xf1, 0xde, 0xf8, 0xf6, 0x49, 0xbd, 0x5f, 0x46, 0x5e, 0x5f, 0x7e, 0xa4, 0x82, + 0x6d, 0x52, 0xc1, 0xbe, 0x52, 0xc1, 0xde, 0x32, 0xd1, 0xd8, 0x64, 0xa2, 0xf1, 0x99, 0x89, 0xc6, + 0xa3, 0x5d, 0x04, 0x50, 0xf0, 0x2a, 0x67, 0xca, 0x59, 0x6d, 0x5f, 0xce, 0x4b, 0x2b, 0xbf, 0x9b, + 0x8b, 0xef, 0x00, 0x00, 0x00, 0xff, 0xff, 0x58, 0xc2, 0x24, 0xb3, 0x56, 0x02, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -303,8 +303,8 @@ const _ = grpc.SupportPackageIsVersion4 // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. type MsgClient interface { - // Create creates a new account in the chain. - Create(ctx context.Context, in *MsgCreate, opts ...grpc.CallOption) (*MsgCreateResponse, error) + // Init creates a new account in the chain. + Init(ctx context.Context, in *MsgInit, opts ...grpc.CallOption) (*MsgInitResponse, error) // Execute executes a message to the target account. Execute(ctx context.Context, in *MsgExecute, opts ...grpc.CallOption) (*MsgExecuteResponse, error) } @@ -317,9 +317,9 @@ func NewMsgClient(cc grpc1.ClientConn) MsgClient { return &msgClient{cc} } -func (c *msgClient) Create(ctx context.Context, in *MsgCreate, opts ...grpc.CallOption) (*MsgCreateResponse, error) { - out := new(MsgCreateResponse) - err := c.cc.Invoke(ctx, "/cosmos.accounts.v1.Msg/Create", in, out, opts...) +func (c *msgClient) Init(ctx context.Context, in *MsgInit, opts ...grpc.CallOption) (*MsgInitResponse, error) { + out := new(MsgInitResponse) + err := c.cc.Invoke(ctx, "/cosmos.accounts.v1.Msg/Init", in, out, opts...) if err != nil { return nil, err } @@ -337,8 +337,8 @@ func (c *msgClient) Execute(ctx context.Context, in *MsgExecute, opts ...grpc.Ca // MsgServer is the server API for Msg service. type MsgServer interface { - // Create creates a new account in the chain. - Create(context.Context, *MsgCreate) (*MsgCreateResponse, error) + // Init creates a new account in the chain. + Init(context.Context, *MsgInit) (*MsgInitResponse, error) // Execute executes a message to the target account. Execute(context.Context, *MsgExecute) (*MsgExecuteResponse, error) } @@ -347,8 +347,8 @@ type MsgServer interface { type UnimplementedMsgServer struct { } -func (*UnimplementedMsgServer) Create(ctx context.Context, req *MsgCreate) (*MsgCreateResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Create not implemented") +func (*UnimplementedMsgServer) Init(ctx context.Context, req *MsgInit) (*MsgInitResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Init not implemented") } func (*UnimplementedMsgServer) Execute(ctx context.Context, req *MsgExecute) (*MsgExecuteResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Execute not implemented") @@ -358,20 +358,20 @@ func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) } -func _Msg_Create_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgCreate) +func _Msg_Init_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgInit) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(MsgServer).Create(ctx, in) + return srv.(MsgServer).Init(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/cosmos.accounts.v1.Msg/Create", + FullMethod: "/cosmos.accounts.v1.Msg/Init", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).Create(ctx, req.(*MsgCreate)) + return srv.(MsgServer).Init(ctx, req.(*MsgInit)) } return interceptor(ctx, in, info, handler) } @@ -399,8 +399,8 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ HandlerType: (*MsgServer)(nil), Methods: []grpc.MethodDesc{ { - MethodName: "Create", - Handler: _Msg_Create_Handler, + MethodName: "Init", + Handler: _Msg_Init_Handler, }, { MethodName: "Execute", @@ -411,7 +411,7 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ Metadata: "cosmos/accounts/v1/tx.proto", } -func (m *MsgCreate) Marshal() (dAtA []byte, err error) { +func (m *MsgInit) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -421,12 +421,12 @@ func (m *MsgCreate) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgCreate) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgInit) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgCreate) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgInit) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -455,7 +455,7 @@ func (m *MsgCreate) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *MsgCreateResponse) Marshal() (dAtA []byte, err error) { +func (m *MsgInitResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -465,12 +465,12 @@ func (m *MsgCreateResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgCreateResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgInitResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgCreateResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgInitResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -577,7 +577,7 @@ func encodeVarintTx(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } -func (m *MsgCreate) Size() (n int) { +func (m *MsgInit) Size() (n int) { if m == nil { return 0 } @@ -598,7 +598,7 @@ func (m *MsgCreate) Size() (n int) { return n } -func (m *MsgCreateResponse) Size() (n int) { +func (m *MsgInitResponse) Size() (n int) { if m == nil { return 0 } @@ -655,7 +655,7 @@ func sovTx(x uint64) (n int) { func sozTx(x uint64) (n int) { return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } -func (m *MsgCreate) Unmarshal(dAtA []byte) error { +func (m *MsgInit) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -678,10 +678,10 @@ func (m *MsgCreate) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgCreate: wiretype end group for non-group") + return fmt.Errorf("proto: MsgInit: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgCreate: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgInit: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -803,7 +803,7 @@ func (m *MsgCreate) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgCreateResponse) Unmarshal(dAtA []byte) error { +func (m *MsgInitResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -826,10 +826,10 @@ func (m *MsgCreateResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgCreateResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgInitResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgCreateResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgInitResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: