From 4a8a15e4d6816ee01568e5e90f708049c3680395 Mon Sep 17 00:00:00 2001 From: Prad Nukala Date: Tue, 26 Nov 2024 13:23:44 -0500 Subject: [PATCH] feat: add fast reflection methods for Capability and Resource --- api/dwn/v1/genesis.pulsar.go | 1155 ++++++++++++++++++++++- api/dwn/v1/state.cosmos_orm.go | 305 ------ api/dwn/v1/state.pulsar.go | 513 ++++++++-- docs/adrs/adr-1.md | 141 +++ docs/adrs/adr-2.md | 145 +++ docs/adrs/adr-3.md | 91 ++ docs/adrs/adr-4.md | 0 docs/reference/guides/cosmos-orm.md | 329 +++++++ docs/reference/guides/cosmos-sdk.md | 3 + docs/reference/guides/echo-framework.md | 3 + docs/reference/guides/templ-syntax.md | 3 + docs/reference/guides/wa-components.md | 3 + x/dwn/types/genesis.pb.go | 506 +++++++++- x/dwn/types/state.pb.go | 296 +++++- 14 files changed, 3010 insertions(+), 483 deletions(-) delete mode 100644 api/dwn/v1/state.cosmos_orm.go create mode 100644 docs/adrs/adr-1.md create mode 100644 docs/adrs/adr-2.md create mode 100644 docs/adrs/adr-3.md create mode 100644 docs/adrs/adr-4.md create mode 100644 docs/reference/guides/cosmos-orm.md create mode 100644 docs/reference/guides/cosmos-sdk.md create mode 100644 docs/reference/guides/echo-framework.md create mode 100644 docs/reference/guides/templ-syntax.md create mode 100644 docs/reference/guides/wa-components.md diff --git a/api/dwn/v1/genesis.pulsar.go b/api/dwn/v1/genesis.pulsar.go index c4ad51b96..fc3b4762f 100644 --- a/api/dwn/v1/genesis.pulsar.go +++ b/api/dwn/v1/genesis.pulsar.go @@ -992,6 +992,974 @@ func (x *fastReflection_Params) ProtoMethods() *protoiface.Methods { } } +var ( + md_Capability protoreflect.MessageDescriptor + fd_Capability_name protoreflect.FieldDescriptor + fd_Capability_description protoreflect.FieldDescriptor +) + +func init() { + file_dwn_v1_genesis_proto_init() + md_Capability = File_dwn_v1_genesis_proto.Messages().ByName("Capability") + fd_Capability_name = md_Capability.Fields().ByName("name") + fd_Capability_description = md_Capability.Fields().ByName("description") +} + +var _ protoreflect.Message = (*fastReflection_Capability)(nil) + +type fastReflection_Capability Capability + +func (x *Capability) ProtoReflect() protoreflect.Message { + return (*fastReflection_Capability)(x) +} + +func (x *Capability) slowProtoReflect() protoreflect.Message { + mi := &file_dwn_v1_genesis_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_Capability_messageType fastReflection_Capability_messageType +var _ protoreflect.MessageType = fastReflection_Capability_messageType{} + +type fastReflection_Capability_messageType struct{} + +func (x fastReflection_Capability_messageType) Zero() protoreflect.Message { + return (*fastReflection_Capability)(nil) +} +func (x fastReflection_Capability_messageType) New() protoreflect.Message { + return new(fastReflection_Capability) +} +func (x fastReflection_Capability_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_Capability +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_Capability) Descriptor() protoreflect.MessageDescriptor { + return md_Capability +} + +// 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_Capability) Type() protoreflect.MessageType { + return _fastReflection_Capability_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_Capability) New() protoreflect.Message { + return new(fastReflection_Capability) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_Capability) Interface() protoreflect.ProtoMessage { + return (*Capability)(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_Capability) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if x.Name != "" { + value := protoreflect.ValueOfString(x.Name) + if !f(fd_Capability_name, value) { + return + } + } + if x.Description != "" { + value := protoreflect.ValueOfString(x.Description) + if !f(fd_Capability_description, 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_Capability) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "dwn.v1.Capability.name": + return x.Name != "" + case "dwn.v1.Capability.description": + return x.Description != "" + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: dwn.v1.Capability")) + } + panic(fmt.Errorf("message dwn.v1.Capability 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_Capability) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "dwn.v1.Capability.name": + x.Name = "" + case "dwn.v1.Capability.description": + x.Description = "" + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: dwn.v1.Capability")) + } + panic(fmt.Errorf("message dwn.v1.Capability 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_Capability) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "dwn.v1.Capability.name": + value := x.Name + return protoreflect.ValueOfString(value) + case "dwn.v1.Capability.description": + value := x.Description + return protoreflect.ValueOfString(value) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: dwn.v1.Capability")) + } + panic(fmt.Errorf("message dwn.v1.Capability 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_Capability) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "dwn.v1.Capability.name": + x.Name = value.Interface().(string) + case "dwn.v1.Capability.description": + x.Description = value.Interface().(string) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: dwn.v1.Capability")) + } + panic(fmt.Errorf("message dwn.v1.Capability 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_Capability) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "dwn.v1.Capability.name": + panic(fmt.Errorf("field name of message dwn.v1.Capability is not mutable")) + case "dwn.v1.Capability.description": + panic(fmt.Errorf("field description of message dwn.v1.Capability is not mutable")) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: dwn.v1.Capability")) + } + panic(fmt.Errorf("message dwn.v1.Capability 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_Capability) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "dwn.v1.Capability.name": + return protoreflect.ValueOfString("") + case "dwn.v1.Capability.description": + return protoreflect.ValueOfString("") + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: dwn.v1.Capability")) + } + panic(fmt.Errorf("message dwn.v1.Capability 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_Capability) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in dwn.v1.Capability", 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_Capability) 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_Capability) 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_Capability) 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_Capability) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*Capability) + 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.Name) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + l = len(x.Description) + 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().(*Capability) + 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.Description) > 0 { + i -= len(x.Description) + copy(dAtA[i:], x.Description) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Description))) + i-- + dAtA[i] = 0x12 + } + if len(x.Name) > 0 { + i -= len(x.Name) + copy(dAtA[i:], x.Name) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Name))) + 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().(*Capability) + 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: Capability: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: Capability: 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 Name", 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.Name = 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 Description", 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.Description = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := runtime.Skip(dAtA[iNdEx:]) + if err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if !options.DiscardUnknown { + x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + } + iNdEx += skippy + } + } + + if iNdEx > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil + } + return &protoiface.Methods{ + NoUnkeyedLiterals: struct{}{}, + Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown, + Size: size, + Marshal: marshal, + Unmarshal: unmarshal, + Merge: nil, + CheckInitialized: nil, + } +} + +var ( + md_Resource protoreflect.MessageDescriptor + fd_Resource_name protoreflect.FieldDescriptor + fd_Resource_description protoreflect.FieldDescriptor +) + +func init() { + file_dwn_v1_genesis_proto_init() + md_Resource = File_dwn_v1_genesis_proto.Messages().ByName("Resource") + fd_Resource_name = md_Resource.Fields().ByName("name") + fd_Resource_description = md_Resource.Fields().ByName("description") +} + +var _ protoreflect.Message = (*fastReflection_Resource)(nil) + +type fastReflection_Resource Resource + +func (x *Resource) ProtoReflect() protoreflect.Message { + return (*fastReflection_Resource)(x) +} + +func (x *Resource) slowProtoReflect() protoreflect.Message { + mi := &file_dwn_v1_genesis_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_Resource_messageType fastReflection_Resource_messageType +var _ protoreflect.MessageType = fastReflection_Resource_messageType{} + +type fastReflection_Resource_messageType struct{} + +func (x fastReflection_Resource_messageType) Zero() protoreflect.Message { + return (*fastReflection_Resource)(nil) +} +func (x fastReflection_Resource_messageType) New() protoreflect.Message { + return new(fastReflection_Resource) +} +func (x fastReflection_Resource_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_Resource +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_Resource) Descriptor() protoreflect.MessageDescriptor { + return md_Resource +} + +// 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_Resource) Type() protoreflect.MessageType { + return _fastReflection_Resource_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_Resource) New() protoreflect.Message { + return new(fastReflection_Resource) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_Resource) Interface() protoreflect.ProtoMessage { + return (*Resource)(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_Resource) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if x.Name != "" { + value := protoreflect.ValueOfString(x.Name) + if !f(fd_Resource_name, value) { + return + } + } + if x.Description != "" { + value := protoreflect.ValueOfString(x.Description) + if !f(fd_Resource_description, 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_Resource) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "dwn.v1.Resource.name": + return x.Name != "" + case "dwn.v1.Resource.description": + return x.Description != "" + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: dwn.v1.Resource")) + } + panic(fmt.Errorf("message dwn.v1.Resource 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_Resource) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "dwn.v1.Resource.name": + x.Name = "" + case "dwn.v1.Resource.description": + x.Description = "" + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: dwn.v1.Resource")) + } + panic(fmt.Errorf("message dwn.v1.Resource 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_Resource) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "dwn.v1.Resource.name": + value := x.Name + return protoreflect.ValueOfString(value) + case "dwn.v1.Resource.description": + value := x.Description + return protoreflect.ValueOfString(value) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: dwn.v1.Resource")) + } + panic(fmt.Errorf("message dwn.v1.Resource 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_Resource) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "dwn.v1.Resource.name": + x.Name = value.Interface().(string) + case "dwn.v1.Resource.description": + x.Description = value.Interface().(string) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: dwn.v1.Resource")) + } + panic(fmt.Errorf("message dwn.v1.Resource 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_Resource) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "dwn.v1.Resource.name": + panic(fmt.Errorf("field name of message dwn.v1.Resource is not mutable")) + case "dwn.v1.Resource.description": + panic(fmt.Errorf("field description of message dwn.v1.Resource is not mutable")) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: dwn.v1.Resource")) + } + panic(fmt.Errorf("message dwn.v1.Resource 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_Resource) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "dwn.v1.Resource.name": + return protoreflect.ValueOfString("") + case "dwn.v1.Resource.description": + return protoreflect.ValueOfString("") + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: dwn.v1.Resource")) + } + panic(fmt.Errorf("message dwn.v1.Resource 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_Resource) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in dwn.v1.Resource", 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_Resource) 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_Resource) 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_Resource) 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_Resource) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*Resource) + 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.Name) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + l = len(x.Description) + 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().(*Resource) + 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.Description) > 0 { + i -= len(x.Description) + copy(dAtA[i:], x.Description) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Description))) + i-- + dAtA[i] = 0x12 + } + if len(x.Name) > 0 { + i -= len(x.Name) + copy(dAtA[i:], x.Name) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Name))) + 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().(*Resource) + 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: Resource: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: Resource: 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 Name", 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.Name = 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 Description", 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.Description = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := runtime.Skip(dAtA[iNdEx:]) + if err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if !options.DiscardUnknown { + x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + } + iNdEx += skippy + } + } + + if iNdEx > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil + } + return &protoiface.Methods{ + NoUnkeyedLiterals: struct{}{}, + Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown, + Size: size, + Marshal: marshal, + Unmarshal: unmarshal, + Merge: nil, + CheckInitialized: nil, + } +} + var ( md_Schema protoreflect.MessageDescriptor fd_Schema_version protoreflect.FieldDescriptor @@ -1030,7 +1998,7 @@ func (x *Schema) ProtoReflect() protoreflect.Message { } func (x *Schema) slowProtoReflect() protoreflect.Message { - mi := &file_dwn_v1_genesis_proto_msgTypes[2] + mi := &file_dwn_v1_genesis_proto_msgTypes[4] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2074,6 +3042,95 @@ func (x *Params) GetSchema() *Schema { return nil } +// Capability reprensents the available capabilities of a decentralized web node +type Capability struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` +} + +func (x *Capability) Reset() { + *x = Capability{} + if protoimpl.UnsafeEnabled { + mi := &file_dwn_v1_genesis_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Capability) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Capability) ProtoMessage() {} + +// Deprecated: Use Capability.ProtoReflect.Descriptor instead. +func (*Capability) Descriptor() ([]byte, []int) { + return file_dwn_v1_genesis_proto_rawDescGZIP(), []int{2} +} + +func (x *Capability) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *Capability) GetDescription() string { + if x != nil { + return x.Description + } + return "" +} + +// Resource reprensents the available resources of a decentralized web node +type Resource struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` +} + +func (x *Resource) Reset() { + *x = Resource{} + if protoimpl.UnsafeEnabled { + mi := &file_dwn_v1_genesis_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Resource) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Resource) ProtoMessage() {} + +// Deprecated: Use Resource.ProtoReflect.Descriptor instead. +func (*Resource) Descriptor() ([]byte, []int) { + return file_dwn_v1_genesis_proto_rawDescGZIP(), []int{3} +} + +func (x *Resource) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *Resource) GetDescription() string { + if x != nil { + return x.Description + } + return "" +} + +// Schema is the Database Model for Decentralized Web Nodes type Schema struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -2094,7 +3151,7 @@ type Schema struct { func (x *Schema) Reset() { *x = Schema{} if protoimpl.UnsafeEnabled { - mi := &file_dwn_v1_genesis_proto_msgTypes[2] + mi := &file_dwn_v1_genesis_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2108,7 +3165,7 @@ func (*Schema) ProtoMessage() {} // Deprecated: Use Schema.ProtoReflect.Descriptor instead. func (*Schema) Descriptor() ([]byte, []int) { - return file_dwn_v1_genesis_proto_rawDescGZIP(), []int{2} + return file_dwn_v1_genesis_proto_rawDescGZIP(), []int{4} } func (x *Schema) GetVersion() int32 { @@ -2203,31 +3260,39 @@ var file_dwn_v1_genesis_proto_rawDesc = []byte{ 0x0e, 0x2e, 0x64, 0x77, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x52, 0x06, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x3a, 0x19, 0x98, 0xa0, 0x1f, 0x00, 0xe8, 0xa0, 0x1f, 0x01, 0x8a, 0xe7, 0xb0, 0x2a, 0x0c, 0x76, 0x61, 0x75, 0x6c, 0x74, 0x2f, 0x70, 0x61, 0x72, 0x61, - 0x6d, 0x73, 0x22, 0xf8, 0x01, 0x0a, 0x06, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x12, 0x18, 0x0a, - 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, - 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, - 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, - 0x74, 0x12, 0x14, 0x0a, 0x05, 0x61, 0x73, 0x73, 0x65, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x05, 0x61, 0x73, 0x73, 0x65, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x68, 0x61, 0x69, 0x6e, - 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x12, 0x1e, 0x0a, - 0x0a, 0x63, 0x72, 0x65, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x18, 0x05, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x0a, 0x63, 0x72, 0x65, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x12, 0x10, 0x0a, - 0x03, 0x64, 0x69, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x64, 0x69, 0x64, 0x12, - 0x10, 0x0a, 0x03, 0x6a, 0x77, 0x6b, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6a, 0x77, - 0x6b, 0x12, 0x14, 0x0a, 0x05, 0x67, 0x72, 0x61, 0x6e, 0x74, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x05, 0x67, 0x72, 0x61, 0x6e, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x6b, 0x65, 0x79, 0x73, 0x68, - 0x61, 0x72, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6b, 0x65, 0x79, 0x73, 0x68, - 0x61, 0x72, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x18, 0x0a, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x70, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x42, 0x7c, 0x0a, - 0x0a, 0x63, 0x6f, 0x6d, 0x2e, 0x64, 0x77, 0x6e, 0x2e, 0x76, 0x31, 0x42, 0x0c, 0x47, 0x65, 0x6e, - 0x65, 0x73, 0x69, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x27, 0x67, 0x69, 0x74, - 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6f, 0x6e, 0x73, 0x6f, 0x6e, 0x72, 0x2f, 0x73, - 0x6f, 0x6e, 0x72, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x64, 0x77, 0x6e, 0x2f, 0x76, 0x31, 0x3b, 0x64, - 0x77, 0x6e, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x44, 0x58, 0x58, 0xaa, 0x02, 0x06, 0x44, 0x77, 0x6e, - 0x2e, 0x56, 0x31, 0xca, 0x02, 0x06, 0x44, 0x77, 0x6e, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x12, 0x44, - 0x77, 0x6e, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, - 0x61, 0xea, 0x02, 0x07, 0x44, 0x77, 0x6e, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x33, + 0x6d, 0x73, 0x22, 0x42, 0x0a, 0x0a, 0x43, 0x61, 0x70, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, + 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, + 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, + 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, + 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x40, 0x0a, 0x08, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, + 0x63, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, + 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, + 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0xf8, 0x01, 0x0a, 0x06, 0x53, 0x63, 0x68, + 0x65, 0x6d, 0x61, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x18, 0x0a, + 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, + 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x61, 0x73, 0x73, 0x65, 0x74, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x61, 0x73, 0x73, 0x65, 0x74, 0x12, 0x14, 0x0a, + 0x05, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x63, 0x68, + 0x61, 0x69, 0x6e, 0x12, 0x1e, 0x0a, 0x0a, 0x63, 0x72, 0x65, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x61, + 0x6c, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x63, 0x72, 0x65, 0x64, 0x65, 0x6e, 0x74, + 0x69, 0x61, 0x6c, 0x12, 0x10, 0x0a, 0x03, 0x64, 0x69, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x03, 0x64, 0x69, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x6a, 0x77, 0x6b, 0x18, 0x07, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x03, 0x6a, 0x77, 0x6b, 0x12, 0x14, 0x0a, 0x05, 0x67, 0x72, 0x61, 0x6e, 0x74, + 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x67, 0x72, 0x61, 0x6e, 0x74, 0x12, 0x1a, 0x0a, + 0x08, 0x6b, 0x65, 0x79, 0x73, 0x68, 0x61, 0x72, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x08, 0x6b, 0x65, 0x79, 0x73, 0x68, 0x61, 0x72, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x72, 0x6f, + 0x66, 0x69, 0x6c, 0x65, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x70, 0x72, 0x6f, 0x66, + 0x69, 0x6c, 0x65, 0x42, 0x7c, 0x0a, 0x0a, 0x63, 0x6f, 0x6d, 0x2e, 0x64, 0x77, 0x6e, 0x2e, 0x76, + 0x31, 0x42, 0x0c, 0x47, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, + 0x01, 0x5a, 0x27, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6f, 0x6e, + 0x73, 0x6f, 0x6e, 0x72, 0x2f, 0x73, 0x6f, 0x6e, 0x72, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x64, 0x77, + 0x6e, 0x2f, 0x76, 0x31, 0x3b, 0x64, 0x77, 0x6e, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x44, 0x58, 0x58, + 0xaa, 0x02, 0x06, 0x44, 0x77, 0x6e, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x06, 0x44, 0x77, 0x6e, 0x5c, + 0x56, 0x31, 0xe2, 0x02, 0x12, 0x44, 0x77, 0x6e, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, + 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x07, 0x44, 0x77, 0x6e, 0x3a, 0x3a, 0x56, + 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -2242,15 +3307,17 @@ func file_dwn_v1_genesis_proto_rawDescGZIP() []byte { return file_dwn_v1_genesis_proto_rawDescData } -var file_dwn_v1_genesis_proto_msgTypes = make([]protoimpl.MessageInfo, 3) +var file_dwn_v1_genesis_proto_msgTypes = make([]protoimpl.MessageInfo, 5) var file_dwn_v1_genesis_proto_goTypes = []interface{}{ (*GenesisState)(nil), // 0: dwn.v1.GenesisState (*Params)(nil), // 1: dwn.v1.Params - (*Schema)(nil), // 2: dwn.v1.Schema + (*Capability)(nil), // 2: dwn.v1.Capability + (*Resource)(nil), // 3: dwn.v1.Resource + (*Schema)(nil), // 4: dwn.v1.Schema } var file_dwn_v1_genesis_proto_depIdxs = []int32{ 1, // 0: dwn.v1.GenesisState.params:type_name -> dwn.v1.Params - 2, // 1: dwn.v1.Params.schema:type_name -> dwn.v1.Schema + 4, // 1: dwn.v1.Params.schema:type_name -> dwn.v1.Schema 2, // [2:2] is the sub-list for method output_type 2, // [2:2] is the sub-list for method input_type 2, // [2:2] is the sub-list for extension type_name @@ -2289,6 +3356,30 @@ func file_dwn_v1_genesis_proto_init() { } } file_dwn_v1_genesis_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Capability); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_dwn_v1_genesis_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Resource); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_dwn_v1_genesis_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Schema); i { case 0: return &v.state @@ -2307,7 +3398,7 @@ func file_dwn_v1_genesis_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_dwn_v1_genesis_proto_rawDesc, NumEnums: 0, - NumMessages: 3, + NumMessages: 5, NumExtensions: 0, NumServices: 0, }, diff --git a/api/dwn/v1/state.cosmos_orm.go b/api/dwn/v1/state.cosmos_orm.go deleted file mode 100644 index a6aa6c240..000000000 --- a/api/dwn/v1/state.cosmos_orm.go +++ /dev/null @@ -1,305 +0,0 @@ -// Code generated by protoc-gen-go-cosmos-orm. DO NOT EDIT. - -package dwnv1 - -import ( - context "context" - ormlist "cosmossdk.io/orm/model/ormlist" - ormtable "cosmossdk.io/orm/model/ormtable" - ormerrors "cosmossdk.io/orm/types/ormerrors" -) - -type CredentialTable interface { - Insert(ctx context.Context, credential *Credential) error - Update(ctx context.Context, credential *Credential) error - Save(ctx context.Context, credential *Credential) error - Delete(ctx context.Context, credential *Credential) error - Has(ctx context.Context, account []byte) (found bool, err error) - // Get returns nil and an error which responds true to ormerrors.IsNotFound() if the record was not found. - Get(ctx context.Context, account []byte) (*Credential, error) - List(ctx context.Context, prefixKey CredentialIndexKey, opts ...ormlist.Option) (CredentialIterator, error) - ListRange(ctx context.Context, from, to CredentialIndexKey, opts ...ormlist.Option) (CredentialIterator, error) - DeleteBy(ctx context.Context, prefixKey CredentialIndexKey) error - DeleteRange(ctx context.Context, from, to CredentialIndexKey) error - - doNotImplement() -} - -type CredentialIterator struct { - ormtable.Iterator -} - -func (i CredentialIterator) Value() (*Credential, error) { - var credential Credential - err := i.UnmarshalMessage(&credential) - return &credential, err -} - -type CredentialIndexKey interface { - id() uint32 - values() []interface{} - credentialIndexKey() -} - -// primary key starting index.. -type CredentialPrimaryKey = CredentialAccountIndexKey - -type CredentialAccountIndexKey struct { - vs []interface{} -} - -func (x CredentialAccountIndexKey) id() uint32 { return 0 } -func (x CredentialAccountIndexKey) values() []interface{} { return x.vs } -func (x CredentialAccountIndexKey) credentialIndexKey() {} - -func (this CredentialAccountIndexKey) WithAccount(account []byte) CredentialAccountIndexKey { - this.vs = []interface{}{account} - return this -} - -type CredentialAmountIndexKey struct { - vs []interface{} -} - -func (x CredentialAmountIndexKey) id() uint32 { return 1 } -func (x CredentialAmountIndexKey) values() []interface{} { return x.vs } -func (x CredentialAmountIndexKey) credentialIndexKey() {} - -func (this CredentialAmountIndexKey) WithAmount(amount uint64) CredentialAmountIndexKey { - this.vs = []interface{}{amount} - return this -} - -type credentialTable struct { - table ormtable.Table -} - -func (this credentialTable) Insert(ctx context.Context, credential *Credential) error { - return this.table.Insert(ctx, credential) -} - -func (this credentialTable) Update(ctx context.Context, credential *Credential) error { - return this.table.Update(ctx, credential) -} - -func (this credentialTable) Save(ctx context.Context, credential *Credential) error { - return this.table.Save(ctx, credential) -} - -func (this credentialTable) Delete(ctx context.Context, credential *Credential) error { - return this.table.Delete(ctx, credential) -} - -func (this credentialTable) Has(ctx context.Context, account []byte) (found bool, err error) { - return this.table.PrimaryKey().Has(ctx, account) -} - -func (this credentialTable) Get(ctx context.Context, account []byte) (*Credential, error) { - var credential Credential - found, err := this.table.PrimaryKey().Get(ctx, &credential, account) - if err != nil { - return nil, err - } - if !found { - return nil, ormerrors.NotFound - } - return &credential, nil -} - -func (this credentialTable) List(ctx context.Context, prefixKey CredentialIndexKey, opts ...ormlist.Option) (CredentialIterator, error) { - it, err := this.table.GetIndexByID(prefixKey.id()).List(ctx, prefixKey.values(), opts...) - return CredentialIterator{it}, err -} - -func (this credentialTable) ListRange(ctx context.Context, from, to CredentialIndexKey, opts ...ormlist.Option) (CredentialIterator, error) { - it, err := this.table.GetIndexByID(from.id()).ListRange(ctx, from.values(), to.values(), opts...) - return CredentialIterator{it}, err -} - -func (this credentialTable) DeleteBy(ctx context.Context, prefixKey CredentialIndexKey) error { - return this.table.GetIndexByID(prefixKey.id()).DeleteBy(ctx, prefixKey.values()...) -} - -func (this credentialTable) DeleteRange(ctx context.Context, from, to CredentialIndexKey) error { - return this.table.GetIndexByID(from.id()).DeleteRange(ctx, from.values(), to.values()) -} - -func (this credentialTable) doNotImplement() {} - -var _ CredentialTable = credentialTable{} - -func NewCredentialTable(db ormtable.Schema) (CredentialTable, error) { - table := db.GetTable(&Credential{}) - if table == nil { - return nil, ormerrors.TableNotFound.Wrap(string((&Credential{}).ProtoReflect().Descriptor().FullName())) - } - return credentialTable{table}, nil -} - -type ProfileTable interface { - Insert(ctx context.Context, profile *Profile) error - Update(ctx context.Context, profile *Profile) error - Save(ctx context.Context, profile *Profile) error - Delete(ctx context.Context, profile *Profile) error - Has(ctx context.Context, account []byte) (found bool, err error) - // Get returns nil and an error which responds true to ormerrors.IsNotFound() if the record was not found. - Get(ctx context.Context, account []byte) (*Profile, error) - List(ctx context.Context, prefixKey ProfileIndexKey, opts ...ormlist.Option) (ProfileIterator, error) - ListRange(ctx context.Context, from, to ProfileIndexKey, opts ...ormlist.Option) (ProfileIterator, error) - DeleteBy(ctx context.Context, prefixKey ProfileIndexKey) error - DeleteRange(ctx context.Context, from, to ProfileIndexKey) error - - doNotImplement() -} - -type ProfileIterator struct { - ormtable.Iterator -} - -func (i ProfileIterator) Value() (*Profile, error) { - var profile Profile - err := i.UnmarshalMessage(&profile) - return &profile, err -} - -type ProfileIndexKey interface { - id() uint32 - values() []interface{} - profileIndexKey() -} - -// primary key starting index.. -type ProfilePrimaryKey = ProfileAccountIndexKey - -type ProfileAccountIndexKey struct { - vs []interface{} -} - -func (x ProfileAccountIndexKey) id() uint32 { return 0 } -func (x ProfileAccountIndexKey) values() []interface{} { return x.vs } -func (x ProfileAccountIndexKey) profileIndexKey() {} - -func (this ProfileAccountIndexKey) WithAccount(account []byte) ProfileAccountIndexKey { - this.vs = []interface{}{account} - return this -} - -type ProfileAmountIndexKey struct { - vs []interface{} -} - -func (x ProfileAmountIndexKey) id() uint32 { return 1 } -func (x ProfileAmountIndexKey) values() []interface{} { return x.vs } -func (x ProfileAmountIndexKey) profileIndexKey() {} - -func (this ProfileAmountIndexKey) WithAmount(amount uint64) ProfileAmountIndexKey { - this.vs = []interface{}{amount} - return this -} - -type profileTable struct { - table ormtable.Table -} - -func (this profileTable) Insert(ctx context.Context, profile *Profile) error { - return this.table.Insert(ctx, profile) -} - -func (this profileTable) Update(ctx context.Context, profile *Profile) error { - return this.table.Update(ctx, profile) -} - -func (this profileTable) Save(ctx context.Context, profile *Profile) error { - return this.table.Save(ctx, profile) -} - -func (this profileTable) Delete(ctx context.Context, profile *Profile) error { - return this.table.Delete(ctx, profile) -} - -func (this profileTable) Has(ctx context.Context, account []byte) (found bool, err error) { - return this.table.PrimaryKey().Has(ctx, account) -} - -func (this profileTable) Get(ctx context.Context, account []byte) (*Profile, error) { - var profile Profile - found, err := this.table.PrimaryKey().Get(ctx, &profile, account) - if err != nil { - return nil, err - } - if !found { - return nil, ormerrors.NotFound - } - return &profile, nil -} - -func (this profileTable) List(ctx context.Context, prefixKey ProfileIndexKey, opts ...ormlist.Option) (ProfileIterator, error) { - it, err := this.table.GetIndexByID(prefixKey.id()).List(ctx, prefixKey.values(), opts...) - return ProfileIterator{it}, err -} - -func (this profileTable) ListRange(ctx context.Context, from, to ProfileIndexKey, opts ...ormlist.Option) (ProfileIterator, error) { - it, err := this.table.GetIndexByID(from.id()).ListRange(ctx, from.values(), to.values(), opts...) - return ProfileIterator{it}, err -} - -func (this profileTable) DeleteBy(ctx context.Context, prefixKey ProfileIndexKey) error { - return this.table.GetIndexByID(prefixKey.id()).DeleteBy(ctx, prefixKey.values()...) -} - -func (this profileTable) DeleteRange(ctx context.Context, from, to ProfileIndexKey) error { - return this.table.GetIndexByID(from.id()).DeleteRange(ctx, from.values(), to.values()) -} - -func (this profileTable) doNotImplement() {} - -var _ ProfileTable = profileTable{} - -func NewProfileTable(db ormtable.Schema) (ProfileTable, error) { - table := db.GetTable(&Profile{}) - if table == nil { - return nil, ormerrors.TableNotFound.Wrap(string((&Profile{}).ProtoReflect().Descriptor().FullName())) - } - return profileTable{table}, nil -} - -type StateStore interface { - CredentialTable() CredentialTable - ProfileTable() ProfileTable - - doNotImplement() -} - -type stateStore struct { - credential CredentialTable - profile ProfileTable -} - -func (x stateStore) CredentialTable() CredentialTable { - return x.credential -} - -func (x stateStore) ProfileTable() ProfileTable { - return x.profile -} - -func (stateStore) doNotImplement() {} - -var _ StateStore = stateStore{} - -func NewStateStore(db ormtable.Schema) (StateStore, error) { - credentialTable, err := NewCredentialTable(db) - if err != nil { - return nil, err - } - - profileTable, err := NewProfileTable(db) - if err != nil { - return nil, err - } - - return stateStore{ - credentialTable, - profileTable, - }, nil -} diff --git a/api/dwn/v1/state.pulsar.go b/api/dwn/v1/state.pulsar.go index eba069b68..58b193c4f 100644 --- a/api/dwn/v1/state.pulsar.go +++ b/api/dwn/v1/state.pulsar.go @@ -13,17 +13,71 @@ import ( sync "sync" ) +var _ protoreflect.List = (*_Credential_3_list)(nil) + +type _Credential_3_list struct { + list *[]string +} + +func (x *_Credential_3_list) Len() int { + if x.list == nil { + return 0 + } + return len(*x.list) +} + +func (x *_Credential_3_list) Get(i int) protoreflect.Value { + return protoreflect.ValueOfString((*x.list)[i]) +} + +func (x *_Credential_3_list) Set(i int, value protoreflect.Value) { + valueUnwrapped := value.String() + concreteValue := valueUnwrapped + (*x.list)[i] = concreteValue +} + +func (x *_Credential_3_list) Append(value protoreflect.Value) { + valueUnwrapped := value.String() + concreteValue := valueUnwrapped + *x.list = append(*x.list, concreteValue) +} + +func (x *_Credential_3_list) AppendMutable() protoreflect.Value { + panic(fmt.Errorf("AppendMutable can not be called on message Credential at list field Transports as it is not of Message kind")) +} + +func (x *_Credential_3_list) Truncate(n int) { + *x.list = (*x.list)[:n] +} + +func (x *_Credential_3_list) NewElement() protoreflect.Value { + v := "" + return protoreflect.ValueOfString(v) +} + +func (x *_Credential_3_list) IsValid() bool { + return x.list != nil +} + var ( - md_Credential protoreflect.MessageDescriptor - fd_Credential_account protoreflect.FieldDescriptor - fd_Credential_amount protoreflect.FieldDescriptor + md_Credential protoreflect.MessageDescriptor + fd_Credential_id protoreflect.FieldDescriptor + fd_Credential_type protoreflect.FieldDescriptor + fd_Credential_transports protoreflect.FieldDescriptor + fd_Credential_public_key protoreflect.FieldDescriptor + fd_Credential_attestation_type protoreflect.FieldDescriptor + fd_Credential_created_at protoreflect.FieldDescriptor ) func init() { file_dwn_v1_state_proto_init() md_Credential = File_dwn_v1_state_proto.Messages().ByName("Credential") - fd_Credential_account = md_Credential.Fields().ByName("account") - fd_Credential_amount = md_Credential.Fields().ByName("amount") + fd_Credential_id = md_Credential.Fields().ByName("id") + fd_Credential_type = md_Credential.Fields().ByName("type") + fd_Credential_transports = md_Credential.Fields().ByName("transports") + fd_Credential_public_key = md_Credential.Fields().ByName("public_key") + fd_Credential_attestation_type = md_Credential.Fields().ByName("attestation_type") + fd_Credential_created_at = md_Credential.Fields().ByName("created_at") } var _ protoreflect.Message = (*fastReflection_Credential)(nil) @@ -91,15 +145,39 @@ func (x *fastReflection_Credential) Interface() protoreflect.ProtoMessage { // While iterating, mutating operations may only be performed // on the current field descriptor. func (x *fastReflection_Credential) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { - if len(x.Account) != 0 { - value := protoreflect.ValueOfBytes(x.Account) - if !f(fd_Credential_account, value) { + if len(x.Id) != 0 { + value := protoreflect.ValueOfBytes(x.Id) + if !f(fd_Credential_id, value) { return } } - if x.Amount != uint64(0) { - value := protoreflect.ValueOfUint64(x.Amount) - if !f(fd_Credential_amount, value) { + if x.Type_ != "" { + value := protoreflect.ValueOfString(x.Type_) + if !f(fd_Credential_type, value) { + return + } + } + if len(x.Transports) != 0 { + value := protoreflect.ValueOfList(&_Credential_3_list{list: &x.Transports}) + if !f(fd_Credential_transports, value) { + return + } + } + if len(x.PublicKey) != 0 { + value := protoreflect.ValueOfBytes(x.PublicKey) + if !f(fd_Credential_public_key, value) { + return + } + } + if x.AttestationType != "" { + value := protoreflect.ValueOfString(x.AttestationType) + if !f(fd_Credential_attestation_type, value) { + return + } + } + if x.CreatedAt != uint64(0) { + value := protoreflect.ValueOfUint64(x.CreatedAt) + if !f(fd_Credential_created_at, value) { return } } @@ -118,10 +196,18 @@ func (x *fastReflection_Credential) Range(f func(protoreflect.FieldDescriptor, p // a repeated field is populated if it is non-empty. func (x *fastReflection_Credential) Has(fd protoreflect.FieldDescriptor) bool { switch fd.FullName() { - case "dwn.v1.Credential.account": - return len(x.Account) != 0 - case "dwn.v1.Credential.amount": - return x.Amount != uint64(0) + case "dwn.v1.Credential.id": + return len(x.Id) != 0 + case "dwn.v1.Credential.type": + return x.Type_ != "" + case "dwn.v1.Credential.transports": + return len(x.Transports) != 0 + case "dwn.v1.Credential.public_key": + return len(x.PublicKey) != 0 + case "dwn.v1.Credential.attestation_type": + return x.AttestationType != "" + case "dwn.v1.Credential.created_at": + return x.CreatedAt != uint64(0) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: dwn.v1.Credential")) @@ -138,10 +224,18 @@ func (x *fastReflection_Credential) Has(fd protoreflect.FieldDescriptor) bool { // Clear is a mutating operation and unsafe for concurrent use. func (x *fastReflection_Credential) Clear(fd protoreflect.FieldDescriptor) { switch fd.FullName() { - case "dwn.v1.Credential.account": - x.Account = nil - case "dwn.v1.Credential.amount": - x.Amount = uint64(0) + case "dwn.v1.Credential.id": + x.Id = nil + case "dwn.v1.Credential.type": + x.Type_ = "" + case "dwn.v1.Credential.transports": + x.Transports = nil + case "dwn.v1.Credential.public_key": + x.PublicKey = nil + case "dwn.v1.Credential.attestation_type": + x.AttestationType = "" + case "dwn.v1.Credential.created_at": + x.CreatedAt = uint64(0) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: dwn.v1.Credential")) @@ -158,11 +252,26 @@ func (x *fastReflection_Credential) Clear(fd protoreflect.FieldDescriptor) { // of the value; to obtain a mutable reference, use Mutable. func (x *fastReflection_Credential) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { switch descriptor.FullName() { - case "dwn.v1.Credential.account": - value := x.Account + case "dwn.v1.Credential.id": + value := x.Id return protoreflect.ValueOfBytes(value) - case "dwn.v1.Credential.amount": - value := x.Amount + case "dwn.v1.Credential.type": + value := x.Type_ + return protoreflect.ValueOfString(value) + case "dwn.v1.Credential.transports": + if len(x.Transports) == 0 { + return protoreflect.ValueOfList(&_Credential_3_list{}) + } + listValue := &_Credential_3_list{list: &x.Transports} + return protoreflect.ValueOfList(listValue) + case "dwn.v1.Credential.public_key": + value := x.PublicKey + return protoreflect.ValueOfBytes(value) + case "dwn.v1.Credential.attestation_type": + value := x.AttestationType + return protoreflect.ValueOfString(value) + case "dwn.v1.Credential.created_at": + value := x.CreatedAt return protoreflect.ValueOfUint64(value) default: if descriptor.IsExtension() { @@ -184,10 +293,20 @@ func (x *fastReflection_Credential) Get(descriptor protoreflect.FieldDescriptor) // Set is a mutating operation and unsafe for concurrent use. func (x *fastReflection_Credential) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { switch fd.FullName() { - case "dwn.v1.Credential.account": - x.Account = value.Bytes() - case "dwn.v1.Credential.amount": - x.Amount = value.Uint() + case "dwn.v1.Credential.id": + x.Id = value.Bytes() + case "dwn.v1.Credential.type": + x.Type_ = value.Interface().(string) + case "dwn.v1.Credential.transports": + lv := value.List() + clv := lv.(*_Credential_3_list) + x.Transports = *clv.list + case "dwn.v1.Credential.public_key": + x.PublicKey = value.Bytes() + case "dwn.v1.Credential.attestation_type": + x.AttestationType = value.Interface().(string) + case "dwn.v1.Credential.created_at": + x.CreatedAt = value.Uint() default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: dwn.v1.Credential")) @@ -208,10 +327,22 @@ func (x *fastReflection_Credential) Set(fd protoreflect.FieldDescriptor, value p // Mutable is a mutating operation and unsafe for concurrent use. func (x *fastReflection_Credential) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { switch fd.FullName() { - case "dwn.v1.Credential.account": - panic(fmt.Errorf("field account of message dwn.v1.Credential is not mutable")) - case "dwn.v1.Credential.amount": - panic(fmt.Errorf("field amount of message dwn.v1.Credential is not mutable")) + case "dwn.v1.Credential.transports": + if x.Transports == nil { + x.Transports = []string{} + } + value := &_Credential_3_list{list: &x.Transports} + return protoreflect.ValueOfList(value) + case "dwn.v1.Credential.id": + panic(fmt.Errorf("field id of message dwn.v1.Credential is not mutable")) + case "dwn.v1.Credential.type": + panic(fmt.Errorf("field type of message dwn.v1.Credential is not mutable")) + case "dwn.v1.Credential.public_key": + panic(fmt.Errorf("field public_key of message dwn.v1.Credential is not mutable")) + case "dwn.v1.Credential.attestation_type": + panic(fmt.Errorf("field attestation_type of message dwn.v1.Credential is not mutable")) + case "dwn.v1.Credential.created_at": + panic(fmt.Errorf("field created_at of message dwn.v1.Credential is not mutable")) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: dwn.v1.Credential")) @@ -225,9 +356,18 @@ func (x *fastReflection_Credential) Mutable(fd protoreflect.FieldDescriptor) pro // For lists, maps, and messages, this returns a new, empty, mutable value. func (x *fastReflection_Credential) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { switch fd.FullName() { - case "dwn.v1.Credential.account": + case "dwn.v1.Credential.id": return protoreflect.ValueOfBytes(nil) - case "dwn.v1.Credential.amount": + case "dwn.v1.Credential.type": + return protoreflect.ValueOfString("") + case "dwn.v1.Credential.transports": + list := []string{} + return protoreflect.ValueOfList(&_Credential_3_list{list: &list}) + case "dwn.v1.Credential.public_key": + return protoreflect.ValueOfBytes(nil) + case "dwn.v1.Credential.attestation_type": + return protoreflect.ValueOfString("") + case "dwn.v1.Credential.created_at": return protoreflect.ValueOfUint64(uint64(0)) default: if fd.IsExtension() { @@ -298,12 +438,30 @@ func (x *fastReflection_Credential) ProtoMethods() *protoiface.Methods { var n int var l int _ = l - l = len(x.Account) + l = len(x.Id) if l > 0 { n += 1 + l + runtime.Sov(uint64(l)) } - if x.Amount != 0 { - n += 1 + runtime.Sov(uint64(x.Amount)) + l = len(x.Type_) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + if len(x.Transports) > 0 { + for _, s := range x.Transports { + l = len(s) + n += 1 + l + runtime.Sov(uint64(l)) + } + } + l = len(x.PublicKey) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + l = len(x.AttestationType) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + if x.CreatedAt != 0 { + n += 1 + runtime.Sov(uint64(x.CreatedAt)) } if x.unknownFields != nil { n += len(x.unknownFields) @@ -334,15 +492,45 @@ func (x *fastReflection_Credential) ProtoMethods() *protoiface.Methods { i -= len(x.unknownFields) copy(dAtA[i:], x.unknownFields) } - if x.Amount != 0 { - i = runtime.EncodeVarint(dAtA, i, uint64(x.Amount)) + if x.CreatedAt != 0 { + i = runtime.EncodeVarint(dAtA, i, uint64(x.CreatedAt)) i-- - dAtA[i] = 0x10 + dAtA[i] = 0x30 } - if len(x.Account) > 0 { - i -= len(x.Account) - copy(dAtA[i:], x.Account) - i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Account))) + if len(x.AttestationType) > 0 { + i -= len(x.AttestationType) + copy(dAtA[i:], x.AttestationType) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.AttestationType))) + i-- + dAtA[i] = 0x2a + } + if len(x.PublicKey) > 0 { + i -= len(x.PublicKey) + copy(dAtA[i:], x.PublicKey) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.PublicKey))) + i-- + dAtA[i] = 0x22 + } + if len(x.Transports) > 0 { + for iNdEx := len(x.Transports) - 1; iNdEx >= 0; iNdEx-- { + i -= len(x.Transports[iNdEx]) + copy(dAtA[i:], x.Transports[iNdEx]) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Transports[iNdEx]))) + i-- + dAtA[i] = 0x1a + } + } + if len(x.Type_) > 0 { + i -= len(x.Type_) + copy(dAtA[i:], x.Type_) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Type_))) + i-- + dAtA[i] = 0x12 + } + if len(x.Id) > 0 { + i -= len(x.Id) + copy(dAtA[i:], x.Id) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Id))) i-- dAtA[i] = 0xa } @@ -397,7 +585,7 @@ func (x *fastReflection_Credential) ProtoMethods() *protoiface.Methods { switch fieldNum { case 1: if wireType != 2 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Account", wireType) + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) } var byteLen int for shift := uint(0); ; shift += 7 { @@ -424,16 +612,16 @@ func (x *fastReflection_Credential) ProtoMethods() *protoiface.Methods { if postIndex > l { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF } - x.Account = append(x.Account[:0], dAtA[iNdEx:postIndex]...) - if x.Account == nil { - x.Account = []byte{} + x.Id = append(x.Id[:0], dAtA[iNdEx:postIndex]...) + if x.Id == nil { + x.Id = []byte{} } iNdEx = postIndex case 2: - if wireType != 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Type_", wireType) } - x.Amount = 0 + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow @@ -443,7 +631,137 @@ func (x *fastReflection_Credential) ProtoMethods() *protoiface.Methods { } b := dAtA[iNdEx] iNdEx++ - x.Amount |= uint64(b&0x7F) << shift + 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.Type_ = 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 Transports", 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.Transports = append(x.Transports, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 4: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field PublicKey", 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.PublicKey = append(x.PublicKey[:0], dAtA[iNdEx:postIndex]...) + if x.PublicKey == nil { + x.PublicKey = []byte{} + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field AttestationType", 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.AttestationType = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 6: + if wireType != 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field CreatedAt", wireType) + } + x.CreatedAt = 0 + 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++ + x.CreatedAt |= uint64(b&0x7F) << shift if b < 0x80 { break } @@ -971,8 +1289,12 @@ type Credential struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Account []byte `protobuf:"bytes,1,opt,name=account,proto3" json:"account,omitempty"` - Amount uint64 `protobuf:"varint,2,opt,name=amount,proto3" json:"amount,omitempty"` + Id []byte `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` // The credential ID as a byte array + Type_ string `protobuf:"bytes,2,opt,name=type,proto3" json:"type,omitempty"` // The credential type (e.g. "public-key") + Transports []string `protobuf:"bytes,3,rep,name=transports,proto3" json:"transports,omitempty"` // Optional transport hints (usb, nfc, ble, internal) + PublicKey []byte `protobuf:"bytes,4,opt,name=public_key,json=publicKey,proto3" json:"public_key,omitempty"` // The credential's public key + AttestationType string `protobuf:"bytes,5,opt,name=attestation_type,json=attestationType,proto3" json:"attestation_type,omitempty"` // The attestation type used (e.g. "none", "indirect", etc) + CreatedAt uint64 `protobuf:"varint,6,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"` // Timestamp of when the credential was created } func (x *Credential) Reset() { @@ -995,16 +1317,44 @@ func (*Credential) Descriptor() ([]byte, []int) { return file_dwn_v1_state_proto_rawDescGZIP(), []int{0} } -func (x *Credential) GetAccount() []byte { +func (x *Credential) GetId() []byte { if x != nil { - return x.Account + return x.Id } return nil } -func (x *Credential) GetAmount() uint64 { +func (x *Credential) GetType_() string { if x != nil { - return x.Amount + return x.Type_ + } + return "" +} + +func (x *Credential) GetTransports() []string { + if x != nil { + return x.Transports + } + return nil +} + +func (x *Credential) GetPublicKey() []byte { + if x != nil { + return x.PublicKey + } + return nil +} + +func (x *Credential) GetAttestationType() string { + if x != nil { + return x.AttestationType + } + return "" +} + +func (x *Credential) GetCreatedAt() uint64 { + if x != nil { + return x.CreatedAt } return 0 } @@ -1058,27 +1408,34 @@ var file_dwn_v1_state_proto_rawDesc = []byte{ 0x0a, 0x12, 0x64, 0x77, 0x6e, 0x2f, 0x76, 0x31, 0x2f, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x06, 0x64, 0x77, 0x6e, 0x2e, 0x76, 0x31, 0x1a, 0x17, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x6f, 0x72, 0x6d, 0x2f, 0x76, 0x31, 0x2f, 0x6f, 0x72, 0x6d, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x5f, 0x0a, 0x0a, 0x43, 0x72, 0x65, 0x64, 0x65, 0x6e, 0x74, - 0x69, 0x61, 0x6c, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x16, 0x0a, - 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x61, - 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x3a, 0x1f, 0xf2, 0x9e, 0xd3, 0x8e, 0x03, 0x19, 0x0a, 0x09, 0x0a, - 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x0a, 0x0a, 0x06, 0x61, 0x6d, 0x6f, 0x75, - 0x6e, 0x74, 0x10, 0x01, 0x18, 0x01, 0x22, 0x5c, 0x0a, 0x07, 0x50, 0x72, 0x6f, 0x66, 0x69, 0x6c, - 0x65, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x0c, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x61, - 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x61, 0x6d, 0x6f, - 0x75, 0x6e, 0x74, 0x3a, 0x1f, 0xf2, 0x9e, 0xd3, 0x8e, 0x03, 0x19, 0x0a, 0x09, 0x0a, 0x07, 0x61, - 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x0a, 0x0a, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, - 0x10, 0x01, 0x18, 0x02, 0x42, 0x7a, 0x0a, 0x0a, 0x63, 0x6f, 0x6d, 0x2e, 0x64, 0x77, 0x6e, 0x2e, - 0x76, 0x31, 0x42, 0x0a, 0x53, 0x74, 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, - 0x5a, 0x27, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6f, 0x6e, 0x73, - 0x6f, 0x6e, 0x72, 0x2f, 0x73, 0x6f, 0x6e, 0x72, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x64, 0x77, 0x6e, - 0x2f, 0x76, 0x31, 0x3b, 0x64, 0x77, 0x6e, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x44, 0x58, 0x58, 0xaa, - 0x02, 0x06, 0x44, 0x77, 0x6e, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x06, 0x44, 0x77, 0x6e, 0x5c, 0x56, - 0x31, 0xe2, 0x02, 0x12, 0x44, 0x77, 0x6e, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, - 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x07, 0x44, 0x77, 0x6e, 0x3a, 0x3a, 0x56, 0x31, - 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xd3, 0x01, 0x0a, 0x0a, 0x43, 0x72, 0x65, 0x64, 0x65, 0x6e, + 0x74, 0x69, 0x61, 0x6c, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, + 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x74, 0x72, 0x61, 0x6e, + 0x73, 0x70, 0x6f, 0x72, 0x74, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0a, 0x74, 0x72, + 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x73, 0x12, 0x1d, 0x0a, 0x0a, 0x70, 0x75, 0x62, 0x6c, + 0x69, 0x63, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x70, 0x75, + 0x62, 0x6c, 0x69, 0x63, 0x4b, 0x65, 0x79, 0x12, 0x29, 0x0a, 0x10, 0x61, 0x74, 0x74, 0x65, 0x73, + 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x0f, 0x61, 0x74, 0x74, 0x65, 0x73, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x79, + 0x70, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, + 0x18, 0x06, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, + 0x74, 0x3a, 0x18, 0xf2, 0x9e, 0xd3, 0x8e, 0x03, 0x12, 0x0a, 0x04, 0x0a, 0x02, 0x69, 0x64, 0x12, + 0x08, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x10, 0x01, 0x18, 0x01, 0x22, 0x5c, 0x0a, 0x07, 0x50, + 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, + 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, + 0x12, 0x16, 0x0a, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, + 0x52, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x3a, 0x1f, 0xf2, 0x9e, 0xd3, 0x8e, 0x03, 0x19, + 0x0a, 0x09, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x0a, 0x0a, 0x06, 0x61, + 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x10, 0x01, 0x18, 0x02, 0x42, 0x7a, 0x0a, 0x0a, 0x63, 0x6f, 0x6d, + 0x2e, 0x64, 0x77, 0x6e, 0x2e, 0x76, 0x31, 0x42, 0x0a, 0x53, 0x74, 0x61, 0x74, 0x65, 0x50, 0x72, + 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x27, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, + 0x6d, 0x2f, 0x6f, 0x6e, 0x73, 0x6f, 0x6e, 0x72, 0x2f, 0x73, 0x6f, 0x6e, 0x72, 0x2f, 0x61, 0x70, + 0x69, 0x2f, 0x64, 0x77, 0x6e, 0x2f, 0x76, 0x31, 0x3b, 0x64, 0x77, 0x6e, 0x76, 0x31, 0xa2, 0x02, + 0x03, 0x44, 0x58, 0x58, 0xaa, 0x02, 0x06, 0x44, 0x77, 0x6e, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x06, + 0x44, 0x77, 0x6e, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x12, 0x44, 0x77, 0x6e, 0x5c, 0x56, 0x31, 0x5c, + 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x07, 0x44, 0x77, + 0x6e, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/docs/adrs/adr-1.md b/docs/adrs/adr-1.md new file mode 100644 index 000000000..e687d0d40 --- /dev/null +++ b/docs/adrs/adr-1.md @@ -0,0 +1,141 @@ +# `x/did` + +The Decentralized Identity module is responsible for managing native Sonr Accounts, their derived wallets, and associated user identification information. + +## State + +The DID module maintains several key state structures: + +### Controller State + +The Controller state represents a Sonr DWN Vault. It includes: +- Unique identifier (number) +- DID +- Sonr address +- Ethereum address +- Bitcoin address +- Public key +- Keyshares pointer +- Claimed block +- Creation block + +### Assertion State + +The Assertion state includes: +- DID +- Controller +- Subject +- Public key +- Assertion type +- Accumulator (metadata) +- Creation block + +### Authentication State + +The Authentication state includes: +- DID +- Controller +- Subject +- Public key +- Credential ID +- Metadata +- Creation block + +### Verification State + +The Verification state includes: +- DID +- Controller +- DID method +- Issuer +- Subject +- Public key +- Verification type +- Metadata +- Creation block + +## State Transitions + +State transitions are triggered by the following messages: +- LinkAssertion +- LinkAuthentication +- UnlinkAssertion +- UnlinkAuthentication +- ExecuteTx +- UpdateParams + +## Messages + +The DID module defines the following messages: + +1. MsgLinkAuthentication +2. MsgLinkAssertion +3. MsgExecuteTx +4. MsgUnlinkAssertion +5. MsgUnlinkAuthentication +6. MsgUpdateParams + +Each message triggers specific state machine behaviors related to managing DIDs, authentications, assertions, and module parameters. + +## Query + +The DID module provides the following query endpoints: + +1. Params: Query all parameters of the module +2. Resolve: Query the DID document by its ID +3. Sign: Sign a message with the DID document +4. Verify: Verify a message with the DID document + +## Params + +The module parameters include: +- Allowed public keys (map of KeyInfo) +- Conveyance preference +- Attestation formats + +## Client + +The module provides gRPC and REST endpoints for all defined messages and queries. + +## Future Improvements + +Potential future improvements could include: +1. Enhanced privacy features for DID operations +2. Integration with more blockchain networks +3. Support for additional key types and cryptographic algorithms +4. Improved revocation mechanisms for credentials and assertions + +## Tests + +Acceptance tests should cover all major functionality, including: +- Creating and managing DIDs +- Linking and unlinking assertions and authentications +- Executing transactions with DIDs +- Querying and resolving DIDs +- Parameter updates + +## Appendix + +### Account + +An Account represents a user's identity within the Sonr ecosystem. It includes information such as the user's public key, associated wallets, and other identification details. + +### Decentralized Identifier (DID) + +A Decentralized Identifier (DID) is a unique identifier that is created, owned, and controlled by the user. It is used to establish a secure and verifiable digital identity. + +### Verifiable Credential (VC) + +A Verifiable Credential (VC) is a digital statement that can be cryptographically verified. It contains claims about a subject (e.g., a user) and is issued by a trusted authority. + +### Key Types + +The module supports various key types, including: +- Role +- Algorithm (e.g., ES256, EdDSA, ES256K) +- Encoding (e.g., hex, base64, multibase) +- Curve (e.g., P256, P384, P521, X25519, X448, Ed25519, Ed448, secp256k1) + +### JSON Web Key (JWK) + +The module supports JSON Web Keys (JWK) for representing cryptographic keys, including properties such as key type (kty), curve (crv), and coordinates (x, y) for EC and OKP keys, as well as modulus (n) and exponent (e) for RSA keys. diff --git a/docs/adrs/adr-2.md b/docs/adrs/adr-2.md new file mode 100644 index 000000000..ecca8c15a --- /dev/null +++ b/docs/adrs/adr-2.md @@ -0,0 +1,145 @@ +# `x/dwn` + +The DWN module is responsible for the management of IPFS deployed Decentralized Web Nodes (DWNs) and their associated data. + +## Concepts + +The DWN module introduces several key concepts: + +1. Decentralized Web Node (DWN): A distributed network for storing and sharing data. +2. Schema: A structure defining the format of various data types in the dwn. +3. IPFS Integration: The module can interact with IPFS for decentralized data storage. + +## State + +The DWN module maintains the following state: + +### DWN State + +The DWN state is stored using the following structure: + +```protobuf +message DWN { + uint64 id = 1; + string alias = 2; + string cid = 3; + string resolver = 4; +} +``` + +This state is indexed by ID, alias, and CID for efficient querying. + +### Params State + +The module parameters are stored in the following structure: + +```protobuf +message Params { + bool ipfs_active = 1; + bool local_registration_enabled = 2; + Schema schema = 4; +} +``` + +### Schema State + +The Schema state defines the structure for various data types: + +```protobuf +message Schema { + int32 version = 1; + string account = 2; + string asset = 3; + string chain = 4; + string credential = 5; + string did = 6; + string jwk = 7; + string grant = 8; + string keyshare = 9; + string profile = 10; +} +``` + +## State Transitions + +State transitions in the DWN module are primarily triggered by: + +1. Updating module parameters +2. Allocating new dwns +3. Syncing DID documents + +## Messages + +The DWN module defines the following message: + +1. `MsgUpdateParams`: Used to update the module parameters. + +```protobuf +message MsgUpdateParams { + string authority = 1; + Params params = 2; +} +``` + +## Begin Block + +No specific begin-block operations are defined for this module. + +## End Block + +No specific end-block operations are defined for this module. + +## Hooks + +The DWN module does not define any hooks. + +## Events + +The DWN module does not explicitly define any events. However, standard Cosmos SDK events may be emitted during state transitions. + +## Client + +The DWN module provides the following gRPC query endpoints: + +1. `Params`: Queries all parameters of the module. +2. `Schema`: Queries the DID document schema. +3. `Allocate`: Initializes a Target DWN available for claims. +4. `Sync`: Queries the DID document by its ID and returns required information. + +## Params + +The module parameters include: + +- `ipfs_active` (bool): Indicates if IPFS integration is active. +- `local_registration_enabled` (bool): Indicates if local registration is enabled. +- `schema` (Schema): Defines the structure for various data types in the dwn. + +## Future Improvements + +Potential future improvements could include: + +1. Enhanced IPFS integration features. +2. Additional authentication mechanisms beyond WebAuthn. +3. Improved DID document management and querying capabilities. + +## Tests + +Acceptance tests should cover: + +1. Parameter updates +2. DWN state management +3. Schema queries +4. DWN allocation process +5. DID document syncing + +## Appendix + +| Concept | Description | +| ------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| Decentralized Web Node (DWN) | A decentralized, distributed, and secure network of nodes that store and share data. It is a decentralized alternative to traditional web hosting services. | +| Decentralized Identifier (DID) | A unique identifier that is created, owned, and controlled by the user. It is used to establish a secure and verifiable digital identity. | +| HTMX (Hypertext Markup Language eXtensions) | A set of extensions to HTML that allow for the creation of interactive web pages. It is used to enhance the user experience and provide additional functionality to web applications. | +| IPFS (InterPlanetary File System) | A decentralized, peer-to-peer network for storing and sharing data. It is a distributed file system that allows for the creation and sharing of content across a network of nodes. | +| WebAuthn (Web Authentication) | A set of APIs that allow websites to request user authentication using biometric or non-biometric factors. | +| WebAssembly (Web Assembly) | A binary instruction format for a stack-based virtual machine. | +| Verifiable Credential (VC) | A digital statement that can be cryptographically verified. | diff --git a/docs/adrs/adr-3.md b/docs/adrs/adr-3.md new file mode 100644 index 000000000..079760c07 --- /dev/null +++ b/docs/adrs/adr-3.md @@ -0,0 +1,91 @@ +# `x/svc` + +The svc module is responsible for managing the registration and authorization of services within the Sonr ecosystem. It provides a secure and verifiable mechanism for registering and authorizing services using Decentralized Identifiers (DIDs). + +## Concepts + +- **Service**: A decentralized svc on the Sonr Blockchain with properties such as ID, authority, origin, name, description, category, tags, and expiry height. +- **Profile**: Represents a DID alias with properties like ID, subject, origin, and controller. +- **Metadata**: Contains information about a svc, including name, description, category, icon, and tags. + +### Dependencies + +- [x/did](https://github.com/onsonr/sonr/tree/master/x/did) +- [x/group](https://github.com/onsonr/sonr/tree/master/x/group) +- [x/nft](https://github.com/onsonr/sonr/tree/master/x/nft) + +## State + +The module uses the following state structures: + +### Metadata + +Stores information about services: + +- Primary key: `id` (auto-increment) +- Unique index: `origin` +- Fields: id, origin, name, description, category, icon (URI), tags + +### Profile + +Stores DID alias information: + +- Primary key: `id` +- Unique index: `subject,origin` +- Fields: id, subject, origin, controller + +## Messages + +### MsgUpdateParams + +Updates the module parameters. Can only be executed by the governance account. + +### MsgRegisterService + +Registers a new svc on the blockchain. Requires a valid TXT record in DNS for the origin. + +## Params + +The module has the following parameters: + +- `categories`: List of allowed svc categories +- `types`: List of allowed svc types + +## Query + +The module provides the following query: + +### Params + +Retrieves all parameters of the module. + +## Client + +### gRPC + +The module provides a gRPC Query svc with the following RPC: + +- `Params`: Get all parameters of the module + +### CLI + +(TODO: Add CLI commands for interacting with the module) + +## Events + +(TODO: List and describe event tags used by the module) + +## Future Improvements + +- Implement svc discovery mechanisms +- Add support for svc reputation and rating systems +- Enhance svc metadata with more detailed information +- Implement svc update and deactivation functionality + +## Tests + +(TODO: Add acceptance tests for the module) + +## Appendix + +This module is part of the Sonr blockchain project and interacts with other modules such as DID and NFT modules to provide a comprehensive decentralized svc ecosystem. diff --git a/docs/adrs/adr-4.md b/docs/adrs/adr-4.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/reference/guides/cosmos-orm.md b/docs/reference/guides/cosmos-orm.md new file mode 100644 index 000000000..65627bf76 --- /dev/null +++ b/docs/reference/guides/cosmos-orm.md @@ -0,0 +1,329 @@ +# ORM + +The Cosmos SDK ORM is a state management library that provides a rich, but opinionated set of tools for managing a +module's state. It provides support for: + +- type safe management of state +- multipart keys +- secondary indexes +- unique indexes +- easy prefix and range queries +- automatic genesis import/export +- automatic query services for clients, including support for light client proofs (still in development) +- indexing state data in external databases (still in development) + +## Design and Philosophy + +The ORM's data model is inspired by the relational data model found in SQL databases. The core abstraction is a table +with a primary key and optional secondary indexes. + +Because the Cosmos SDK uses protobuf as its encoding layer, ORM tables are defined directly in .proto files using +protobuf options. Each table is defined by a single protobuf `message` type and a schema of multiple tables is +represented by a single .proto file. + +Table structure is specified in the same file where messages are defined in order to make it easy to focus on better +design of the state layer. Because blockchain state layout is part of the public API for clients (TODO: link to docs on +light client proofs), it is important to think about the state layout as being part of the public API of a module. +Changing the state layout actually breaks clients, so it is ideal to think through it carefully up front and to aim for +a design that will eliminate or minimize breaking changes down the road. Also, good design of state enables building +more performant and sophisticated applications. Providing users with a set of tools inspired by relational databases +which have a long history of database design best practices and allowing schema to be specified declaratively in a +single place are design choices the ORM makes to enable better design and more durable APIs. + +Also, by only supporting the table abstraction as opposed to key-value pair maps, it is easy to add to new +columns/fields to any data structure without causing a breaking change and the data structures can easily be indexed in +any off-the-shelf SQL database for more sophisticated queries. + +The encoding of fields in keys is designed to support ordered iteration for all protobuf primitive field types +except for `bytes` as well as the well-known types `google.protobuf.Timestamp` and `google.protobuf.Duration`. Encodings +are optimized for storage space when it makes sense (see the documentation in `cosmos/orm/v1/orm.proto` for more details) +and table rows do not use extra storage space to store key fields in the value. + +We recommend that users of the ORM attempt to follow database design best practices such as +[normalization](https://en.wikipedia.org/wiki/Database_normalization) (at least 1NF). +For instance, defining `repeated` fields in a table is considered an anti-pattern because breaks first normal form (1NF). +Although we support `repeated` fields in tables, they cannot be used as key fields for this reason. This may seem +restrictive but years of best practice (and also experience in the SDK) have shown that following this pattern +leads to easier to maintain schemas. + +To illustrate the motivation for these principles with an example from the SDK, historically balances were stored +as a mapping from account -> map of denom to amount. This did not scale well because an account with 100 token balances +needed to be encoded/decoded every time a single coin balance changed. Now balances are stored as account,denom -> amount +as in the example above. With the ORM's data model, if we wanted to add a new field to `Balance` such as +`unlocked_balance` (if vesting accounts were redesigned in this way), it would be easy to add it to this table without +requiring a data migration. Because of the ORM's optimizations, the account and denom are only stored in the key part +of storage and not in the value leading to both a flexible data model and efficient usage of storage. + +## Defining Tables + +To define a table: + +1. create a .proto file to describe the module's state (naming it `state.proto` is recommended for consistency), + and import "cosmos/orm/v1/orm.proto", ex: + +```protobuf +syntax = "proto3"; +package bank_example; + +import "cosmos/orm/v1/orm.proto"; +``` + +2. define a `message` for the table, ex: + +```protobuf +message Balance { + bytes account = 1; + string denom = 2; + uint64 balance = 3; +} +``` + +3. add the `cosmos.orm.v1.table` option to the table and give the table an `id` unique within this .proto file: + +```protobuf +message Balance { + option (cosmos.orm.v1.table) = { + id: 1 + }; + + bytes account = 1; + string denom = 2; + uint64 balance = 3; +} +``` + +4. define the primary key field or fields, as a comma-separated list of the fields from the message which should make + up the primary key: + +```protobuf +message Balance { + option (cosmos.orm.v1.table) = { + id: 1 + primary_key: { fields: "account,denom" } + }; + + bytes account = 1; + string denom = 2; + uint64 balance = 3; +} +``` + +5. add any desired secondary indexes by specifying an `id` unique within the table and a comma-separate list of the + index fields: + +```protobuf +message Balance { + option (cosmos.orm.v1.table) = { + id: 1; + primary_key: { fields: "account,denom" } + index: { id: 1 fields: "denom" } // this allows querying for the accounts which own a denom + }; + + bytes account = 1; + string denom = 2; + uint64 amount = 3; +} +``` + +### Auto-incrementing Primary Keys + +A common pattern in SDK modules and in database design is to define tables with a single integer `id` field with an +automatically generated primary key. In the ORM we can do this by setting the `auto_increment` option to `true` on the +primary key, ex: + +```protobuf +message Account { + option (cosmos.orm.v1.table) = { + id: 2; + primary_key: { fields: "id", auto_increment: true } + }; + + uint64 id = 1; + bytes address = 2; +} +``` + +### Unique Indexes + +A unique index can be added by setting the `unique` option to `true` on an index, ex: + +```protobuf +message Account { + option (cosmos.orm.v1.table) = { + id: 2; + primary_key: { fields: "id", auto_increment: true } + index: {id: 1, fields: "address", unique: true} + }; + + uint64 id = 1; + bytes address = 2; +} +``` + +### Singletons + +The ORM also supports a special type of table with only one row called a `singleton`. This can be used for storing +module parameters. Singletons only need to define a unique `id` and that cannot conflict with the id of other +tables or singletons in the same .proto file. Ex: + +```protobuf +message Params { + option (cosmos.orm.v1.singleton) = { + id: 3; + }; + + google.protobuf.Duration voting_period = 1; + uint64 min_threshold = 2; +} +``` + +## Running Codegen + +NOTE: the ORM will only work with protobuf code that implements the [google.golang.org/protobuf](https://pkg.go.dev/google.golang.org/protobuf) +API. That means it will not work with code generated using gogo-proto. + +To install the ORM's code generator, run: + +```shell +go install cosmossdk.io/orm/cmd/protoc-gen-go-cosmos-orm@latest +``` + +The recommended way to run the code generator is to use [buf build](https://docs.buf.build/build/usage). +This is an example `buf.gen.yaml` that runs `protoc-gen-go`, `protoc-gen-go-grpc` and `protoc-gen-go-cosmos-orm` +using buf managed mode: + +```yaml +version: v1 +managed: + enabled: true + go_package_prefix: + default: foo.bar/api # the go package prefix of your package + override: + buf.build/cosmos/cosmos-sdk: cosmossdk.io/api # required to import the Cosmos SDK api module +plugins: + - name: go + out: . + opt: paths=source_relative + - name: go-grpc + out: . + opt: paths=source_relative + - name: go-cosmos-orm + out: . + opt: paths=source_relative +``` + +## Using the ORM in a module + +### Initialization + +To use the ORM in a module, first create a `ModuleSchemaDescriptor`. This tells the ORM which .proto files have defined +an ORM schema and assigns them all a unique non-zero id. Ex: + +```go +var MyModuleSchema = &ormv1alpha1.ModuleSchemaDescriptor{ + SchemaFile: []*ormv1alpha1.ModuleSchemaDescriptor_FileEntry{ + { + Id: 1, + ProtoFileName: mymodule.File_my_module_state_proto.Path(), + }, + }, +} +``` + +In the ORM generated code for a file named `state.proto`, there should be an interface `StateStore` that got generated +with a constructor `NewStateStore` that takes a parameter of type `ormdb.ModuleDB`. Add a reference to `StateStore` +to your module's keeper struct. Ex: + +```go +type Keeper struct { + db StateStore +} +``` + +Then instantiate the `StateStore` instance via an `ormdb.ModuleDB` that is instantiated from the `SchemaDescriptor` +above and one or more store services from `cosmossdk.io/core/store`. Ex: + +```go +func NewKeeper(storeService store.KVStoreService) (*Keeper, error) { + modDb, err := ormdb.NewModuleDB(MyModuleSchema, ormdb.ModuleDBOptions{KVStoreService: storeService}) + if err != nil { + return nil, err + } + db, err := NewStateStore(modDb) + if err != nil { + return nil, err + } + return Keeper{db: db}, nil +} +``` + +### Using the generated code + +The generated code for the ORM contains methods for inserting, updating, deleting and querying table entries. +For each table in a .proto file, there is a type-safe table interface implemented in generated code. For instance, +for a table named `Balance` there should be a `BalanceTable` interface that looks like this: + +```go +type BalanceTable interface { + Insert(ctx context.Context, balance *Balance) error + Update(ctx context.Context, balance *Balance) error + Save(ctx context.Context, balance *Balance) error + Delete(ctx context.Context, balance *Balance) error + Has(ctx context.Context, account []byte, denom string) (found bool, err error) + // Get returns nil and an error which responds true to ormerrors.IsNotFound() if the record was not found. + Get(ctx context.Context, account []byte, denom string) (*Balance, error) + List(ctx context.Context, prefixKey BalanceIndexKey, opts ...ormlist.Option) (BalanceIterator, error) + ListRange(ctx context.Context, from, to BalanceIndexKey, opts ...ormlist.Option) (BalanceIterator, error) + DeleteBy(ctx context.Context, prefixKey BalanceIndexKey) error + DeleteRange(ctx context.Context, from, to BalanceIndexKey) error + + doNotImplement() +} +``` + +This `BalanceTable` should be accessible from the `StateStore` interface (assuming our file is named `state.proto`) +via a `BalanceTable()` accessor method. If all the above example tables/singletons were in the same `state.proto`, +then `StateStore` would get generated like this: + +```go +type BankStore interface { + BalanceTable() BalanceTable + AccountTable() AccountTable + ParamsTable() ParamsTable + + doNotImplement() +} +``` + +So to work with the `BalanceTable` in a keeper method we could use code like this: + +```go +func (k keeper) AddBalance(ctx context.Context, acct []byte, denom string, amount uint64) error { + balance, err := k.db.BalanceTable().Get(ctx, acct, denom) + if err != nil && !ormerrors.IsNotFound(err) { + return err + } + + if balance == nil { + balance = &Balance{ + Account: acct, + Denom: denom, + Amount: amount, + } + } else { + balance.Amount = balance.Amount + amount + } + + return k.db.BalanceTable().Save(ctx, balance) +} +``` + +`List` methods take `IndexKey` parameters. For instance, `BalanceTable.List` takes `BalanceIndexKey`. `BalanceIndexKey` +let's represent index keys for the different indexes (primary and secondary) on the `Balance` table. The primary key +in the `Balance` table gets a struct `BalanceAccountDenomIndexKey` and the first index gets an index key `BalanceDenomIndexKey`. +If we wanted to list all the denoms and amounts that an account holds, we would use `BalanceAccountDenomIndexKey` +with a `List` query just on the account prefix. Ex: + +```go +it, err := keeper.db.BalanceTable().List(ctx, BalanceAccountDenomIndexKey{}.WithAccount(acct)) +``` diff --git a/docs/reference/guides/cosmos-sdk.md b/docs/reference/guides/cosmos-sdk.md new file mode 100644 index 000000000..dea85ad75 --- /dev/null +++ b/docs/reference/guides/cosmos-sdk.md @@ -0,0 +1,3 @@ +# Cosmos SDK + +The Cosmos SDK is a modular framework for building blockchain applications. Sonr is built on top of the Cosmos SDK, which provides a robust and secure foundation for building decentralized applications. diff --git a/docs/reference/guides/echo-framework.md b/docs/reference/guides/echo-framework.md new file mode 100644 index 000000000..232447377 --- /dev/null +++ b/docs/reference/guides/echo-framework.md @@ -0,0 +1,3 @@ +# Echo Framework + +The Echo Framework is a web framework for building RESTful APIs in Go. It provides a simple and intuitive way to define routes, handle requests, and return responses. It uses `net/http` underneath to provide minimal external dependencies. diff --git a/docs/reference/guides/templ-syntax.md b/docs/reference/guides/templ-syntax.md new file mode 100644 index 000000000..b9a22c881 --- /dev/null +++ b/docs/reference/guides/templ-syntax.md @@ -0,0 +1,3 @@ +# Templ Syntax + +Templ is a template engine for Go that provides a simple and intuitive way to generate dynamic content. diff --git a/docs/reference/guides/wa-components.md b/docs/reference/guides/wa-components.md new file mode 100644 index 000000000..3753d379e --- /dev/null +++ b/docs/reference/guides/wa-components.md @@ -0,0 +1,3 @@ +# WebAwesome Components + +WebAwesome Components is a collection of reusable web components for building web applications. It provides a set of pre-built components that can be easily integrated into your web application. diff --git a/x/dwn/types/genesis.pb.go b/x/dwn/types/genesis.pb.go index 430981ca0..969bc9fc8 100644 --- a/x/dwn/types/genesis.pb.go +++ b/x/dwn/types/genesis.pb.go @@ -130,6 +130,113 @@ func (m *Params) GetSchema() *Schema { return nil } +// Capability reprensents the available capabilities of a decentralized web node +type Capability struct { + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` +} + +func (m *Capability) Reset() { *m = Capability{} } +func (m *Capability) String() string { return proto.CompactTextString(m) } +func (*Capability) ProtoMessage() {} +func (*Capability) Descriptor() ([]byte, []int) { + return fileDescriptor_8e7492a25d5871dc, []int{2} +} +func (m *Capability) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Capability) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Capability.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 *Capability) XXX_Merge(src proto.Message) { + xxx_messageInfo_Capability.Merge(m, src) +} +func (m *Capability) XXX_Size() int { + return m.Size() +} +func (m *Capability) XXX_DiscardUnknown() { + xxx_messageInfo_Capability.DiscardUnknown(m) +} + +var xxx_messageInfo_Capability proto.InternalMessageInfo + +func (m *Capability) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +func (m *Capability) GetDescription() string { + if m != nil { + return m.Description + } + return "" +} + +// Resource reprensents the available resources of a decentralized web node +type Resource struct { + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` +} + +func (m *Resource) Reset() { *m = Resource{} } +func (m *Resource) String() string { return proto.CompactTextString(m) } +func (*Resource) ProtoMessage() {} +func (*Resource) Descriptor() ([]byte, []int) { + return fileDescriptor_8e7492a25d5871dc, []int{3} +} +func (m *Resource) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Resource) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Resource.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 *Resource) XXX_Merge(src proto.Message) { + xxx_messageInfo_Resource.Merge(m, src) +} +func (m *Resource) XXX_Size() int { + return m.Size() +} +func (m *Resource) XXX_DiscardUnknown() { + xxx_messageInfo_Resource.DiscardUnknown(m) +} + +var xxx_messageInfo_Resource proto.InternalMessageInfo + +func (m *Resource) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +func (m *Resource) GetDescription() string { + if m != nil { + return m.Description + } + return "" +} + +// Schema is the Database Model for Decentralized Web Nodes type Schema struct { Version int32 `protobuf:"varint,1,opt,name=version,proto3" json:"version,omitempty"` Account string `protobuf:"bytes,2,opt,name=account,proto3" json:"account,omitempty"` @@ -147,7 +254,7 @@ func (m *Schema) Reset() { *m = Schema{} } func (m *Schema) String() string { return proto.CompactTextString(m) } func (*Schema) ProtoMessage() {} func (*Schema) Descriptor() ([]byte, []int) { - return fileDescriptor_8e7492a25d5871dc, []int{2} + return fileDescriptor_8e7492a25d5871dc, []int{4} } func (m *Schema) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -249,40 +356,45 @@ func (m *Schema) GetProfile() string { func init() { proto.RegisterType((*GenesisState)(nil), "dwn.v1.GenesisState") proto.RegisterType((*Params)(nil), "dwn.v1.Params") + proto.RegisterType((*Capability)(nil), "dwn.v1.Capability") + proto.RegisterType((*Resource)(nil), "dwn.v1.Resource") proto.RegisterType((*Schema)(nil), "dwn.v1.Schema") } func init() { proto.RegisterFile("dwn/v1/genesis.proto", fileDescriptor_8e7492a25d5871dc) } var fileDescriptor_8e7492a25d5871dc = []byte{ - // 431 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x54, 0x92, 0x31, 0x6f, 0x13, 0x31, - 0x1c, 0xc5, 0xef, 0x68, 0x73, 0x4d, 0xdc, 0x0a, 0x81, 0x95, 0xc1, 0x64, 0xb8, 0xa0, 0x0c, 0x08, - 0x21, 0x74, 0xa7, 0xc2, 0x86, 0xb2, 0x50, 0x09, 0xb1, 0xa2, 0xeb, 0xc6, 0x12, 0x39, 0xbe, 0x7f, - 0x2f, 0x6e, 0x2e, 0xf6, 0xc9, 0x76, 0x2e, 0xf4, 0x2b, 0x30, 0x31, 0x32, 0x76, 0x66, 0xe2, 0x63, - 0x74, 0xec, 0xc8, 0x84, 0x50, 0x32, 0xc0, 0x47, 0x60, 0x44, 0xfe, 0xfb, 0x8a, 0xd2, 0xc5, 0xf2, - 0xfb, 0xbd, 0xe7, 0xa7, 0x37, 0x98, 0x0c, 0xcb, 0x8d, 0xca, 0xdb, 0xd3, 0xbc, 0x02, 0x05, 0x56, - 0xda, 0xac, 0x31, 0xda, 0x69, 0x9a, 0x94, 0x1b, 0x95, 0xb5, 0xa7, 0xa3, 0x61, 0xa5, 0x2b, 0x8d, - 0x28, 0xf7, 0xb7, 0xe0, 0x8e, 0x1e, 0xf3, 0x95, 0x54, 0x3a, 0xc7, 0x33, 0xa0, 0xc9, 0x94, 0x9c, - 0xbc, 0x0f, 0x0d, 0xe7, 0x8e, 0x3b, 0xa0, 0x2f, 0x49, 0xd2, 0x70, 0xc3, 0x57, 0x96, 0xc5, 0x4f, - 0xe3, 0xe7, 0xc7, 0xaf, 0x1e, 0x66, 0xa1, 0x31, 0xfb, 0x80, 0xf4, 0xec, 0xf0, 0xe6, 0xe7, 0x38, - 0x2a, 0xba, 0xcc, 0xe4, 0x5b, 0x4c, 0x92, 0x60, 0xd0, 0x31, 0x39, 0x96, 0xcd, 0x85, 0x9d, 0x71, - 0xe1, 0x64, 0x0b, 0xf8, 0xba, 0x5f, 0x10, 0x8f, 0xde, 0x22, 0xa1, 0x53, 0x32, 0xaa, 0xb5, 0xe0, - 0xf5, 0xcc, 0x40, 0x25, 0xad, 0x33, 0xdc, 0x49, 0xad, 0x66, 0xa0, 0xf8, 0xbc, 0x86, 0x92, 0x3d, - 0xc0, 0x3c, 0xc3, 0x44, 0xb1, 0x17, 0x78, 0x17, 0x7c, 0xfa, 0x8c, 0x24, 0x56, 0x2c, 0x60, 0xc5, - 0xd9, 0xe1, 0xfd, 0x5d, 0xe7, 0x48, 0x8b, 0xce, 0x7d, 0xf3, 0xe4, 0xeb, 0xf5, 0x38, 0xfa, 0x73, - 0x3d, 0x8e, 0x3f, 0xff, 0xfe, 0xfe, 0xe2, 0xa4, 0xe5, 0xeb, 0xda, 0xe5, 0xdd, 0xd8, 0xbf, 0x31, - 0x49, 0x42, 0x9a, 0x32, 0x72, 0xd4, 0x82, 0xb1, 0x52, 0x2b, 0x1c, 0xda, 0x2b, 0xee, 0xa4, 0x77, - 0xb8, 0x10, 0x7a, 0xad, 0x1c, 0x4e, 0x1a, 0x14, 0x77, 0x92, 0x0e, 0x49, 0x8f, 0x5b, 0x0b, 0x8e, - 0x1d, 0x20, 0x0f, 0xc2, 0x53, 0xb1, 0xe0, 0x52, 0xe1, 0xac, 0x41, 0x11, 0x04, 0x4d, 0x09, 0x11, - 0x06, 0x4a, 0x50, 0x4e, 0xf2, 0x9a, 0xf5, 0xd0, 0xda, 0x23, 0xf4, 0x11, 0x39, 0x28, 0x65, 0xc9, - 0x12, 0x34, 0xfc, 0xd5, 0x93, 0xcb, 0xcd, 0x92, 0x1d, 0x05, 0x72, 0xb9, 0x59, 0xfa, 0xe6, 0xca, - 0x70, 0xe5, 0x58, 0x3f, 0x34, 0xa3, 0xa0, 0x23, 0xd2, 0x5f, 0xc2, 0x95, 0x5d, 0x70, 0x03, 0x6c, - 0x80, 0xc6, 0x7f, 0xed, 0xb7, 0x37, 0x46, 0x5f, 0xc8, 0x1a, 0x18, 0x09, 0xdb, 0x3b, 0x79, 0x36, - 0xbd, 0xd9, 0xa6, 0xf1, 0xed, 0x36, 0x8d, 0x7f, 0x6d, 0xd3, 0xf8, 0xcb, 0x2e, 0x8d, 0x6e, 0x77, - 0x69, 0xf4, 0x63, 0x97, 0x46, 0x1f, 0x27, 0x95, 0x74, 0x8b, 0xf5, 0x3c, 0x13, 0x7a, 0x95, 0x6b, - 0x65, 0xb5, 0x32, 0x39, 0x1e, 0x9f, 0x72, 0xff, 0xbf, 0xdc, 0x55, 0x03, 0x76, 0x9e, 0xe0, 0x57, - 0x79, 0xfd, 0x2f, 0x00, 0x00, 0xff, 0xff, 0xdd, 0xa9, 0xd7, 0xe1, 0x73, 0x02, 0x00, 0x00, + // 478 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x92, 0x31, 0x8f, 0xd3, 0x30, + 0x1c, 0xc5, 0x13, 0xae, 0xcd, 0xb5, 0xff, 0x9e, 0x10, 0x58, 0x1d, 0x4c, 0x87, 0xf4, 0xd4, 0x01, + 0x21, 0x84, 0x12, 0x1d, 0x6c, 0xa8, 0x03, 0x14, 0x21, 0x56, 0x94, 0xdb, 0x58, 0x2a, 0xd7, 0xf1, + 0xa5, 0xbe, 0x26, 0x76, 0x64, 0xbb, 0x29, 0xfd, 0x0a, 0x4c, 0x8c, 0x8c, 0x37, 0x33, 0xf1, 0x31, + 0x6e, 0xbc, 0x91, 0x09, 0xa1, 0x76, 0x80, 0x8f, 0xc0, 0x88, 0x6c, 0xe7, 0x50, 0x59, 0x6f, 0xb1, + 0xfe, 0xef, 0xf7, 0xfe, 0x79, 0x79, 0xb2, 0x0c, 0xc3, 0x7c, 0x23, 0xd2, 0xe6, 0x2c, 0x2d, 0x98, + 0x60, 0x9a, 0xeb, 0xa4, 0x56, 0xd2, 0x48, 0x14, 0xe5, 0x1b, 0x91, 0x34, 0x67, 0xa3, 0x61, 0x21, + 0x0b, 0xe9, 0x50, 0x6a, 0x27, 0xef, 0x8e, 0x1e, 0x92, 0x8a, 0x0b, 0x99, 0xba, 0xd3, 0xa3, 0xc9, + 0x14, 0x4e, 0xde, 0xf9, 0x84, 0x73, 0x43, 0x0c, 0x43, 0xcf, 0x20, 0xaa, 0x89, 0x22, 0x95, 0xc6, + 0xe1, 0x69, 0xf8, 0x64, 0xf0, 0xfc, 0x7e, 0xe2, 0x13, 0x93, 0xf7, 0x8e, 0xce, 0x3a, 0xd7, 0x3f, + 0xc6, 0x41, 0xd6, 0xee, 0x4c, 0xbe, 0x86, 0x10, 0x79, 0x03, 0x8d, 0x61, 0xc0, 0xeb, 0x0b, 0x3d, + 0x27, 0xd4, 0xf0, 0x86, 0xb9, 0xaf, 0x7b, 0x19, 0x58, 0xf4, 0xda, 0x11, 0x34, 0x85, 0x51, 0x29, + 0x29, 0x29, 0xe7, 0x8a, 0x15, 0x5c, 0x1b, 0x45, 0x0c, 0x97, 0x62, 0xce, 0x04, 0x59, 0x94, 0x2c, + 0xc7, 0xf7, 0xdc, 0x3e, 0x76, 0x1b, 0xd9, 0xc1, 0xc2, 0x5b, 0xef, 0xa3, 0xc7, 0x10, 0x69, 0xba, + 0x64, 0x15, 0xc1, 0x9d, 0xff, 0x7b, 0x9d, 0x3b, 0x9a, 0xb5, 0xee, 0xcb, 0x47, 0x5f, 0xae, 0xc6, + 0xc1, 0xef, 0xab, 0x71, 0xf8, 0xe9, 0xd7, 0xb7, 0xa7, 0x27, 0x0d, 0x59, 0x97, 0x26, 0x6d, 0xcb, + 0xce, 0x00, 0xde, 0x90, 0x9a, 0x2c, 0x78, 0xc9, 0xcd, 0x16, 0x21, 0xe8, 0x08, 0x52, 0xf9, 0xa2, + 0xfd, 0xcc, 0xcd, 0xe8, 0x14, 0x06, 0x39, 0xd3, 0x54, 0xf1, 0xda, 0xfe, 0xda, 0x75, 0xea, 0x67, + 0x87, 0x68, 0xf2, 0x0a, 0x7a, 0x19, 0xd3, 0x72, 0xad, 0x28, 0xbb, 0x63, 0xc2, 0x9f, 0x10, 0x22, + 0xdf, 0x19, 0x61, 0x38, 0x6e, 0x98, 0xd2, 0x76, 0xd1, 0x66, 0x74, 0xb3, 0x5b, 0x69, 0x1d, 0x42, + 0xa9, 0x5c, 0x0b, 0xd3, 0x46, 0xdc, 0x4a, 0x34, 0x84, 0x2e, 0xd1, 0x9a, 0x19, 0x7c, 0xe4, 0xb8, + 0x17, 0x96, 0xd2, 0x25, 0xe1, 0xc2, 0x5d, 0x4e, 0x3f, 0xf3, 0x02, 0xc5, 0x00, 0x54, 0xb1, 0x9c, + 0x09, 0xc3, 0x49, 0x89, 0xbb, 0xce, 0x3a, 0x20, 0xe8, 0x01, 0x1c, 0xe5, 0x3c, 0xc7, 0x91, 0x33, + 0xec, 0x68, 0xc9, 0xe5, 0x66, 0x85, 0x8f, 0x3d, 0xb9, 0xdc, 0xac, 0x6c, 0x72, 0xa1, 0x88, 0x30, + 0xb8, 0xe7, 0x93, 0x9d, 0x40, 0x23, 0xe8, 0xad, 0xd8, 0x56, 0x2f, 0x89, 0x62, 0xb8, 0xef, 0x8c, + 0x7f, 0xda, 0x76, 0xaf, 0x95, 0xbc, 0xe0, 0x25, 0xc3, 0xe0, 0xbb, 0xb7, 0x72, 0x36, 0xbd, 0xde, + 0xc5, 0xe1, 0xcd, 0x2e, 0x0e, 0x7f, 0xee, 0xe2, 0xf0, 0xf3, 0x3e, 0x0e, 0x6e, 0xf6, 0x71, 0xf0, + 0x7d, 0x1f, 0x07, 0x1f, 0x26, 0x05, 0x37, 0xcb, 0xf5, 0x22, 0xa1, 0xb2, 0x4a, 0xa5, 0xd0, 0x52, + 0xa8, 0xd4, 0x1d, 0x1f, 0x53, 0xfb, 0xca, 0xcd, 0xb6, 0x66, 0x7a, 0x11, 0xb9, 0x07, 0xfb, 0xe2, + 0x6f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xfa, 0x30, 0xe3, 0x96, 0xf9, 0x02, 0x00, 0x00, } func (this *Params) Equal(that interface{}) bool { @@ -403,6 +515,80 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *Capability) 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 *Capability) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Capability) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Description) > 0 { + i -= len(m.Description) + copy(dAtA[i:], m.Description) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.Description))) + i-- + dAtA[i] = 0x12 + } + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *Resource) 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 *Resource) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Resource) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Description) > 0 { + i -= len(m.Description) + copy(dAtA[i:], m.Description) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.Description))) + i-- + dAtA[i] = 0x12 + } + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func (m *Schema) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -535,6 +721,40 @@ func (m *Params) Size() (n int) { return n } +func (m *Capability) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Name) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + l = len(m.Description) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + return n +} + +func (m *Resource) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Name) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + l = len(m.Description) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + return n +} + func (m *Schema) Size() (n int) { if m == nil { return 0 @@ -798,6 +1018,234 @@ func (m *Params) Unmarshal(dAtA []byte) error { } return nil } +func (m *Capability) 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 ErrIntOverflowGenesis + } + 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: Capability: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Capability: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + 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 ErrInvalidLengthGenesis + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + 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 ErrInvalidLengthGenesis + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Description = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Resource) 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 ErrIntOverflowGenesis + } + 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: Resource: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Resource: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + 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 ErrInvalidLengthGenesis + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + 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 ErrInvalidLengthGenesis + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Description = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *Schema) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/x/dwn/types/state.pb.go b/x/dwn/types/state.pb.go index 50a481acf..d84aba9ef 100644 --- a/x/dwn/types/state.pb.go +++ b/x/dwn/types/state.pb.go @@ -24,8 +24,12 @@ var _ = math.Inf const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type Credential struct { - Account []byte `protobuf:"bytes,1,opt,name=account,proto3" json:"account,omitempty"` - Amount uint64 `protobuf:"varint,2,opt,name=amount,proto3" json:"amount,omitempty"` + Id []byte `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Type string `protobuf:"bytes,2,opt,name=type,proto3" json:"type,omitempty"` + Transports []string `protobuf:"bytes,3,rep,name=transports,proto3" json:"transports,omitempty"` + PublicKey []byte `protobuf:"bytes,4,opt,name=public_key,json=publicKey,proto3" json:"public_key,omitempty"` + AttestationType string `protobuf:"bytes,5,opt,name=attestation_type,json=attestationType,proto3" json:"attestation_type,omitempty"` + CreatedAt uint64 `protobuf:"varint,6,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"` } func (m *Credential) Reset() { *m = Credential{} } @@ -61,16 +65,44 @@ func (m *Credential) XXX_DiscardUnknown() { var xxx_messageInfo_Credential proto.InternalMessageInfo -func (m *Credential) GetAccount() []byte { +func (m *Credential) GetId() []byte { if m != nil { - return m.Account + return m.Id } return nil } -func (m *Credential) GetAmount() uint64 { +func (m *Credential) GetType() string { if m != nil { - return m.Amount + return m.Type + } + return "" +} + +func (m *Credential) GetTransports() []string { + if m != nil { + return m.Transports + } + return nil +} + +func (m *Credential) GetPublicKey() []byte { + if m != nil { + return m.PublicKey + } + return nil +} + +func (m *Credential) GetAttestationType() string { + if m != nil { + return m.AttestationType + } + return "" +} + +func (m *Credential) GetCreatedAt() uint64 { + if m != nil { + return m.CreatedAt } return 0 } @@ -135,21 +167,29 @@ func init() { func init() { proto.RegisterFile("dwn/v1/state.proto", fileDescriptor_040a9b061177db90) } var fileDescriptor_040a9b061177db90 = []byte{ - // 219 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x4a, 0x29, 0xcf, 0xd3, - 0x2f, 0x33, 0xd4, 0x2f, 0x2e, 0x49, 0x2c, 0x49, 0xd5, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, - 0x4b, 0x29, 0xcf, 0xd3, 0x2b, 0x33, 0x94, 0x12, 0x4f, 0xce, 0x2f, 0xce, 0xcd, 0x2f, 0xd6, 0xcf, - 0x2f, 0xca, 0x05, 0x29, 0xc9, 0x2f, 0xca, 0x85, 0x28, 0x50, 0x8a, 0xe7, 0xe2, 0x72, 0x2e, 0x4a, - 0x4d, 0x49, 0xcd, 0x2b, 0xc9, 0x4c, 0xcc, 0x11, 0x92, 0xe0, 0x62, 0x4f, 0x4c, 0x4e, 0xce, 0x2f, - 0xcd, 0x2b, 0x91, 0x60, 0x54, 0x60, 0xd4, 0xe0, 0x09, 0x82, 0x71, 0x85, 0xc4, 0xb8, 0xd8, 0x12, - 0x73, 0xc1, 0x12, 0x4c, 0x0a, 0x8c, 0x1a, 0x2c, 0x41, 0x50, 0x9e, 0x95, 0xfc, 0xa7, 0x79, 0x97, - 0xfb, 0x98, 0x25, 0xb9, 0x38, 0xe1, 0x3a, 0x85, 0xb8, 0x60, 0x4a, 0x05, 0x18, 0x25, 0x18, 0x95, - 0x62, 0xb8, 0xd8, 0x03, 0x8a, 0xf2, 0xd3, 0x32, 0x73, 0x52, 0xa9, 0x6f, 0x3a, 0x93, 0x93, 0xcd, - 0x89, 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, 0xe1, 0xb1, 0x1c, - 0xc3, 0x85, 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, 0x29, 0xa5, 0x67, 0x96, 0x64, 0x94, - 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0xe7, 0xe7, 0x15, 0xe7, 0xe7, 0x15, 0xe9, 0x83, 0x89, 0x0a, - 0x7d, 0x50, 0x30, 0x95, 0x54, 0x16, 0xa4, 0x16, 0x27, 0xb1, 0x81, 0xc3, 0xc0, 0x18, 0x10, 0x00, - 0x00, 0xff, 0xff, 0x14, 0x0b, 0x56, 0x1c, 0x3a, 0x01, 0x00, 0x00, + // 342 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x4c, 0x91, 0xb1, 0x4e, 0xeb, 0x30, + 0x18, 0x85, 0xeb, 0x34, 0x37, 0xbd, 0xf9, 0x75, 0x75, 0x6f, 0xe5, 0xe1, 0x62, 0x90, 0x1a, 0xa2, + 0x4e, 0x61, 0x69, 0x54, 0xb1, 0x55, 0x2c, 0xc0, 0xc8, 0x82, 0x22, 0x26, 0x84, 0x54, 0xb9, 0x89, + 0x01, 0x8b, 0xc6, 0x8e, 0xec, 0xbf, 0x2d, 0x7d, 0x09, 0xc4, 0x13, 0xf0, 0x3c, 0x8c, 0x95, 0xba, + 0x30, 0xa2, 0xf6, 0x0d, 0x78, 0x02, 0x14, 0xb7, 0x45, 0x5d, 0x2c, 0x9f, 0xe3, 0xe3, 0xcf, 0xc7, + 0x36, 0xd0, 0x62, 0xa6, 0xd2, 0x69, 0x3f, 0xb5, 0xc8, 0x51, 0xf4, 0x2a, 0xa3, 0x51, 0xd3, 0xa0, + 0x98, 0xa9, 0xde, 0xb4, 0x7f, 0x74, 0x90, 0x6b, 0x5b, 0x6a, 0x9b, 0x6a, 0x53, 0xd6, 0x11, 0x6d, + 0xca, 0x4d, 0xa0, 0xbb, 0x24, 0x00, 0x97, 0x46, 0x14, 0x42, 0xa1, 0xe4, 0x63, 0xfa, 0x17, 0x3c, + 0x59, 0x30, 0x12, 0x93, 0xe4, 0x4f, 0xe6, 0xc9, 0x82, 0x52, 0xf0, 0x71, 0x5e, 0x09, 0xe6, 0xc5, + 0x24, 0x09, 0x33, 0x37, 0xa7, 0x11, 0x00, 0x1a, 0xae, 0x6c, 0xa5, 0x0d, 0x5a, 0xd6, 0x8c, 0x9b, + 0x49, 0x98, 0xed, 0x39, 0xb4, 0x03, 0x50, 0x4d, 0x46, 0x63, 0x99, 0x0f, 0x9f, 0xc4, 0x9c, 0xf9, + 0x8e, 0x15, 0x6e, 0x9c, 0x2b, 0x31, 0xa7, 0x27, 0xd0, 0xe6, 0x88, 0xa2, 0x6e, 0x29, 0xb5, 0x1a, + 0x3a, 0xfc, 0x2f, 0x87, 0xff, 0xb7, 0xe7, 0xdf, 0xd4, 0x27, 0x75, 0x00, 0x72, 0x23, 0x38, 0x8a, + 0x62, 0xc8, 0x91, 0x05, 0x31, 0x49, 0xfc, 0x2c, 0xdc, 0x3a, 0xe7, 0x38, 0x60, 0x5f, 0x6f, 0xcb, + 0x97, 0x26, 0x05, 0xbf, 0x2e, 0x4d, 0x7f, 0x6f, 0xaa, 0xb6, 0x09, 0x23, 0xdd, 0x3b, 0x68, 0x5d, + 0x1b, 0x7d, 0x2f, 0xc7, 0x82, 0x32, 0x68, 0xf1, 0x3c, 0xd7, 0x13, 0x85, 0xdb, 0x6b, 0xed, 0x24, + 0xfd, 0x0f, 0x01, 0x2f, 0xdd, 0x82, 0xe7, 0xc8, 0x5b, 0x35, 0x38, 0x76, 0xd8, 0x43, 0x08, 0x7f, + 0x76, 0x52, 0xd8, 0x45, 0xdb, 0x84, 0x79, 0x17, 0x67, 0xef, 0xab, 0x88, 0x2c, 0x56, 0x11, 0xf9, + 0x5c, 0x45, 0xe4, 0x75, 0x1d, 0x35, 0x16, 0xeb, 0xa8, 0xf1, 0xb1, 0x8e, 0x1a, 0xb7, 0xdd, 0x07, + 0x89, 0x8f, 0x93, 0x51, 0x2f, 0xd7, 0x65, 0xaa, 0x95, 0xd5, 0xca, 0xa4, 0x6e, 0x78, 0x4e, 0xeb, + 0xbf, 0xa9, 0xeb, 0xd9, 0x51, 0xe0, 0x1e, 0xfe, 0xf4, 0x3b, 0x00, 0x00, 0xff, 0xff, 0x23, 0x73, + 0xed, 0xc6, 0xaf, 0x01, 0x00, 0x00, } func (m *Credential) Marshal() (dAtA []byte, err error) { @@ -172,15 +212,45 @@ func (m *Credential) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if m.Amount != 0 { - i = encodeVarintState(dAtA, i, uint64(m.Amount)) + if m.CreatedAt != 0 { + i = encodeVarintState(dAtA, i, uint64(m.CreatedAt)) i-- - dAtA[i] = 0x10 + dAtA[i] = 0x30 } - if len(m.Account) > 0 { - i -= len(m.Account) - copy(dAtA[i:], m.Account) - i = encodeVarintState(dAtA, i, uint64(len(m.Account))) + if len(m.AttestationType) > 0 { + i -= len(m.AttestationType) + copy(dAtA[i:], m.AttestationType) + i = encodeVarintState(dAtA, i, uint64(len(m.AttestationType))) + i-- + dAtA[i] = 0x2a + } + if len(m.PublicKey) > 0 { + i -= len(m.PublicKey) + copy(dAtA[i:], m.PublicKey) + i = encodeVarintState(dAtA, i, uint64(len(m.PublicKey))) + i-- + dAtA[i] = 0x22 + } + if len(m.Transports) > 0 { + for iNdEx := len(m.Transports) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Transports[iNdEx]) + copy(dAtA[i:], m.Transports[iNdEx]) + i = encodeVarintState(dAtA, i, uint64(len(m.Transports[iNdEx]))) + i-- + dAtA[i] = 0x1a + } + } + if len(m.Type) > 0 { + i -= len(m.Type) + copy(dAtA[i:], m.Type) + i = encodeVarintState(dAtA, i, uint64(len(m.Type))) + i-- + dAtA[i] = 0x12 + } + if len(m.Id) > 0 { + i -= len(m.Id) + copy(dAtA[i:], m.Id) + i = encodeVarintState(dAtA, i, uint64(len(m.Id))) i-- dAtA[i] = 0xa } @@ -239,12 +309,30 @@ func (m *Credential) Size() (n int) { } var l int _ = l - l = len(m.Account) + l = len(m.Id) if l > 0 { n += 1 + l + sovState(uint64(l)) } - if m.Amount != 0 { - n += 1 + sovState(uint64(m.Amount)) + l = len(m.Type) + if l > 0 { + n += 1 + l + sovState(uint64(l)) + } + if len(m.Transports) > 0 { + for _, s := range m.Transports { + l = len(s) + n += 1 + l + sovState(uint64(l)) + } + } + l = len(m.PublicKey) + if l > 0 { + n += 1 + l + sovState(uint64(l)) + } + l = len(m.AttestationType) + if l > 0 { + n += 1 + l + sovState(uint64(l)) + } + if m.CreatedAt != 0 { + n += 1 + sovState(uint64(m.CreatedAt)) } return n } @@ -302,7 +390,7 @@ func (m *Credential) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Account", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) } var byteLen int for shift := uint(0); ; shift += 7 { @@ -329,16 +417,16 @@ func (m *Credential) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Account = append(m.Account[:0], dAtA[iNdEx:postIndex]...) - if m.Account == nil { - m.Account = []byte{} + m.Id = append(m.Id[:0], dAtA[iNdEx:postIndex]...) + if m.Id == nil { + m.Id = []byte{} } iNdEx = postIndex case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Type", wireType) } - m.Amount = 0 + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowState @@ -348,7 +436,137 @@ func (m *Credential) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Amount |= uint64(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthState + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthState + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Type = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Transports", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowState + } + 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 ErrInvalidLengthState + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthState + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Transports = append(m.Transports, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PublicKey", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowState + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthState + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthState + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PublicKey = append(m.PublicKey[:0], dAtA[iNdEx:postIndex]...) + if m.PublicKey == nil { + m.PublicKey = []byte{} + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AttestationType", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowState + } + 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 ErrInvalidLengthState + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthState + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AttestationType = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CreatedAt", wireType) + } + m.CreatedAt = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowState + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.CreatedAt |= uint64(b&0x7F) << shift if b < 0x80 { break }