From f89260bacd520b11d48c6d6a41b4b74d3cd6b7e3 Mon Sep 17 00:00:00 2001 From: Prad Nukala Date: Tue, 26 Nov 2024 20:51:58 -0500 Subject: [PATCH] feat: add support for parent field and resources list in Capability message --- api/dwn/v1/genesis.pulsar.go | 333 ++++++++++++++++++++++++++------- api/dwn/v1/state.cosmos_orm.go | 292 +++++++++++++++++++++++++++++ api/dwn/v1/state.pulsar.go | 90 ++++----- proto/dwn/v1/genesis.proto | 8 +- proto/dwn/v1/state.proto | 3 +- x/dwn/keeper/keeper.go | 1 - x/dwn/types/genesis.go | 31 +++ x/dwn/types/genesis.pb.go | 215 +++++++++++++++------ x/dwn/types/state.pb.go | 64 +++---- 9 files changed, 838 insertions(+), 199 deletions(-) create mode 100644 api/dwn/v1/state.cosmos_orm.go diff --git a/api/dwn/v1/genesis.pulsar.go b/api/dwn/v1/genesis.pulsar.go index fc3b4762f..cb51912b1 100644 --- a/api/dwn/v1/genesis.pulsar.go +++ b/api/dwn/v1/genesis.pulsar.go @@ -992,17 +992,67 @@ func (x *fastReflection_Params) ProtoMethods() *protoiface.Methods { } } +var _ protoreflect.List = (*_Capability_4_list)(nil) + +type _Capability_4_list struct { + list *[]string +} + +func (x *_Capability_4_list) Len() int { + if x.list == nil { + return 0 + } + return len(*x.list) +} + +func (x *_Capability_4_list) Get(i int) protoreflect.Value { + return protoreflect.ValueOfString((*x.list)[i]) +} + +func (x *_Capability_4_list) Set(i int, value protoreflect.Value) { + valueUnwrapped := value.String() + concreteValue := valueUnwrapped + (*x.list)[i] = concreteValue +} + +func (x *_Capability_4_list) Append(value protoreflect.Value) { + valueUnwrapped := value.String() + concreteValue := valueUnwrapped + *x.list = append(*x.list, concreteValue) +} + +func (x *_Capability_4_list) AppendMutable() protoreflect.Value { + panic(fmt.Errorf("AppendMutable can not be called on message Capability at list field Resources as it is not of Message kind")) +} + +func (x *_Capability_4_list) Truncate(n int) { + *x.list = (*x.list)[:n] +} + +func (x *_Capability_4_list) NewElement() protoreflect.Value { + v := "" + return protoreflect.ValueOfString(v) +} + +func (x *_Capability_4_list) IsValid() bool { + return x.list != nil +} + var ( md_Capability protoreflect.MessageDescriptor fd_Capability_name protoreflect.FieldDescriptor + fd_Capability_parent protoreflect.FieldDescriptor fd_Capability_description protoreflect.FieldDescriptor + fd_Capability_resources 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_parent = md_Capability.Fields().ByName("parent") fd_Capability_description = md_Capability.Fields().ByName("description") + fd_Capability_resources = md_Capability.Fields().ByName("resources") } var _ protoreflect.Message = (*fastReflection_Capability)(nil) @@ -1076,12 +1126,24 @@ func (x *fastReflection_Capability) Range(f func(protoreflect.FieldDescriptor, p return } } + if x.Parent != "" { + value := protoreflect.ValueOfString(x.Parent) + if !f(fd_Capability_parent, value) { + return + } + } if x.Description != "" { value := protoreflect.ValueOfString(x.Description) if !f(fd_Capability_description, value) { return } } + if len(x.Resources) != 0 { + value := protoreflect.ValueOfList(&_Capability_4_list{list: &x.Resources}) + if !f(fd_Capability_resources, value) { + return + } + } } // Has reports whether a field is populated. @@ -1099,8 +1161,12 @@ func (x *fastReflection_Capability) Has(fd protoreflect.FieldDescriptor) bool { switch fd.FullName() { case "dwn.v1.Capability.name": return x.Name != "" + case "dwn.v1.Capability.parent": + return x.Parent != "" case "dwn.v1.Capability.description": return x.Description != "" + case "dwn.v1.Capability.resources": + return len(x.Resources) != 0 default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: dwn.v1.Capability")) @@ -1119,8 +1185,12 @@ func (x *fastReflection_Capability) Clear(fd protoreflect.FieldDescriptor) { switch fd.FullName() { case "dwn.v1.Capability.name": x.Name = "" + case "dwn.v1.Capability.parent": + x.Parent = "" case "dwn.v1.Capability.description": x.Description = "" + case "dwn.v1.Capability.resources": + x.Resources = nil default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: dwn.v1.Capability")) @@ -1140,9 +1210,18 @@ func (x *fastReflection_Capability) Get(descriptor protoreflect.FieldDescriptor) case "dwn.v1.Capability.name": value := x.Name return protoreflect.ValueOfString(value) + case "dwn.v1.Capability.parent": + value := x.Parent + return protoreflect.ValueOfString(value) case "dwn.v1.Capability.description": value := x.Description return protoreflect.ValueOfString(value) + case "dwn.v1.Capability.resources": + if len(x.Resources) == 0 { + return protoreflect.ValueOfList(&_Capability_4_list{}) + } + listValue := &_Capability_4_list{list: &x.Resources} + return protoreflect.ValueOfList(listValue) default: if descriptor.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: dwn.v1.Capability")) @@ -1165,8 +1244,14 @@ func (x *fastReflection_Capability) Set(fd protoreflect.FieldDescriptor, value p switch fd.FullName() { case "dwn.v1.Capability.name": x.Name = value.Interface().(string) + case "dwn.v1.Capability.parent": + x.Parent = value.Interface().(string) case "dwn.v1.Capability.description": x.Description = value.Interface().(string) + case "dwn.v1.Capability.resources": + lv := value.List() + clv := lv.(*_Capability_4_list) + x.Resources = *clv.list default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: dwn.v1.Capability")) @@ -1187,8 +1272,16 @@ func (x *fastReflection_Capability) Set(fd protoreflect.FieldDescriptor, value p // 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.resources": + if x.Resources == nil { + x.Resources = []string{} + } + value := &_Capability_4_list{list: &x.Resources} + return protoreflect.ValueOfList(value) case "dwn.v1.Capability.name": panic(fmt.Errorf("field name of message dwn.v1.Capability is not mutable")) + case "dwn.v1.Capability.parent": + panic(fmt.Errorf("field parent 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: @@ -1206,8 +1299,13 @@ func (x *fastReflection_Capability) NewField(fd protoreflect.FieldDescriptor) pr switch fd.FullName() { case "dwn.v1.Capability.name": return protoreflect.ValueOfString("") + case "dwn.v1.Capability.parent": + return protoreflect.ValueOfString("") case "dwn.v1.Capability.description": return protoreflect.ValueOfString("") + case "dwn.v1.Capability.resources": + list := []string{} + return protoreflect.ValueOfList(&_Capability_4_list{list: &list}) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: dwn.v1.Capability")) @@ -1281,10 +1379,20 @@ func (x *fastReflection_Capability) ProtoMethods() *protoiface.Methods { if l > 0 { n += 1 + l + runtime.Sov(uint64(l)) } + l = len(x.Parent) + 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 len(x.Resources) > 0 { + for _, s := range x.Resources { + l = len(s) + n += 1 + l + runtime.Sov(uint64(l)) + } + } if x.unknownFields != nil { n += len(x.unknownFields) } @@ -1314,11 +1422,27 @@ func (x *fastReflection_Capability) ProtoMethods() *protoiface.Methods { i -= len(x.unknownFields) copy(dAtA[i:], x.unknownFields) } + if len(x.Resources) > 0 { + for iNdEx := len(x.Resources) - 1; iNdEx >= 0; iNdEx-- { + i -= len(x.Resources[iNdEx]) + copy(dAtA[i:], x.Resources[iNdEx]) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Resources[iNdEx]))) + i-- + dAtA[i] = 0x22 + } + } 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] = 0x1a + } + if len(x.Parent) > 0 { + i -= len(x.Parent) + copy(dAtA[i:], x.Parent) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Parent))) + i-- dAtA[i] = 0x12 } if len(x.Name) > 0 { @@ -1410,6 +1534,38 @@ func (x *fastReflection_Capability) ProtoMethods() *protoiface.Methods { 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 Parent", 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.Parent = 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 Description", wireType) } @@ -1441,6 +1597,38 @@ func (x *fastReflection_Capability) ProtoMethods() *protoiface.Methods { } x.Description = 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 Resources", 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.Resources = append(x.Resources, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := runtime.Skip(dAtA[iNdEx:]) @@ -1477,16 +1665,16 @@ func (x *fastReflection_Capability) ProtoMethods() *protoiface.Methods { } var ( - md_Resource protoreflect.MessageDescriptor - fd_Resource_name protoreflect.FieldDescriptor - fd_Resource_description protoreflect.FieldDescriptor + md_Resource protoreflect.MessageDescriptor + fd_Resource_kind protoreflect.FieldDescriptor + fd_Resource_template 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") + fd_Resource_kind = md_Resource.Fields().ByName("kind") + fd_Resource_template = md_Resource.Fields().ByName("template") } var _ protoreflect.Message = (*fastReflection_Resource)(nil) @@ -1554,15 +1742,15 @@ func (x *fastReflection_Resource) Interface() protoreflect.ProtoMessage { // 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) { + if x.Kind != "" { + value := protoreflect.ValueOfString(x.Kind) + if !f(fd_Resource_kind, value) { return } } - if x.Description != "" { - value := protoreflect.ValueOfString(x.Description) - if !f(fd_Resource_description, value) { + if x.Template != "" { + value := protoreflect.ValueOfString(x.Template) + if !f(fd_Resource_template, value) { return } } @@ -1581,10 +1769,10 @@ func (x *fastReflection_Resource) Range(f func(protoreflect.FieldDescriptor, pro // 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 != "" + case "dwn.v1.Resource.kind": + return x.Kind != "" + case "dwn.v1.Resource.template": + return x.Template != "" default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: dwn.v1.Resource")) @@ -1601,10 +1789,10 @@ func (x *fastReflection_Resource) Has(fd protoreflect.FieldDescriptor) bool { // 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 = "" + case "dwn.v1.Resource.kind": + x.Kind = "" + case "dwn.v1.Resource.template": + x.Template = "" default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: dwn.v1.Resource")) @@ -1621,11 +1809,11 @@ func (x *fastReflection_Resource) Clear(fd protoreflect.FieldDescriptor) { // 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 + case "dwn.v1.Resource.kind": + value := x.Kind return protoreflect.ValueOfString(value) - case "dwn.v1.Resource.description": - value := x.Description + case "dwn.v1.Resource.template": + value := x.Template return protoreflect.ValueOfString(value) default: if descriptor.IsExtension() { @@ -1647,10 +1835,10 @@ func (x *fastReflection_Resource) Get(descriptor protoreflect.FieldDescriptor) p // 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) + case "dwn.v1.Resource.kind": + x.Kind = value.Interface().(string) + case "dwn.v1.Resource.template": + x.Template = value.Interface().(string) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: dwn.v1.Resource")) @@ -1671,10 +1859,10 @@ func (x *fastReflection_Resource) Set(fd protoreflect.FieldDescriptor, value pro // 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")) + case "dwn.v1.Resource.kind": + panic(fmt.Errorf("field kind of message dwn.v1.Resource is not mutable")) + case "dwn.v1.Resource.template": + panic(fmt.Errorf("field template 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")) @@ -1688,9 +1876,9 @@ func (x *fastReflection_Resource) Mutable(fd protoreflect.FieldDescriptor) proto // 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": + case "dwn.v1.Resource.kind": return protoreflect.ValueOfString("") - case "dwn.v1.Resource.description": + case "dwn.v1.Resource.template": return protoreflect.ValueOfString("") default: if fd.IsExtension() { @@ -1761,11 +1949,11 @@ func (x *fastReflection_Resource) ProtoMethods() *protoiface.Methods { var n int var l int _ = l - l = len(x.Name) + l = len(x.Kind) if l > 0 { n += 1 + l + runtime.Sov(uint64(l)) } - l = len(x.Description) + l = len(x.Template) if l > 0 { n += 1 + l + runtime.Sov(uint64(l)) } @@ -1798,17 +1986,17 @@ func (x *fastReflection_Resource) ProtoMethods() *protoiface.Methods { 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))) + if len(x.Template) > 0 { + i -= len(x.Template) + copy(dAtA[i:], x.Template) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Template))) 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))) + if len(x.Kind) > 0 { + i -= len(x.Kind) + copy(dAtA[i:], x.Kind) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Kind))) i-- dAtA[i] = 0xa } @@ -1863,7 +2051,7 @@ func (x *fastReflection_Resource) 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 Name", wireType) + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Kind", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1891,11 +2079,11 @@ func (x *fastReflection_Resource) ProtoMethods() *protoiface.Methods { if postIndex > l { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF } - x.Name = string(dAtA[iNdEx:postIndex]) + x.Kind = 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) + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Template", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1923,7 +2111,7 @@ func (x *fastReflection_Resource) ProtoMethods() *protoiface.Methods { if postIndex > l { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF } - x.Description = string(dAtA[iNdEx:postIndex]) + x.Template = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex @@ -3048,8 +3236,10 @@ type Capability struct { 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"` + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + Parent string `protobuf:"bytes,2,opt,name=parent,proto3" json:"parent,omitempty"` + Description string `protobuf:"bytes,3,opt,name=description,proto3" json:"description,omitempty"` + Resources []string `protobuf:"bytes,4,rep,name=resources,proto3" json:"resources,omitempty"` } func (x *Capability) Reset() { @@ -3079,6 +3269,13 @@ func (x *Capability) GetName() string { return "" } +func (x *Capability) GetParent() string { + if x != nil { + return x.Parent + } + return "" +} + func (x *Capability) GetDescription() string { if x != nil { return x.Description @@ -3086,14 +3283,21 @@ func (x *Capability) GetDescription() string { return "" } +func (x *Capability) GetResources() []string { + if x != nil { + return x.Resources + } + return nil +} + // 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"` + Kind string `protobuf:"bytes,1,opt,name=kind,proto3" json:"kind,omitempty"` + Template string `protobuf:"bytes,2,opt,name=template,proto3" json:"template,omitempty"` } func (x *Resource) Reset() { @@ -3116,16 +3320,16 @@ func (*Resource) Descriptor() ([]byte, []int) { return file_dwn_v1_genesis_proto_rawDescGZIP(), []int{3} } -func (x *Resource) GetName() string { +func (x *Resource) GetKind() string { if x != nil { - return x.Name + return x.Kind } return "" } -func (x *Resource) GetDescription() string { +func (x *Resource) GetTemplate() string { if x != nil { - return x.Description + return x.Template } return "" } @@ -3260,15 +3464,18 @@ 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, 0x42, 0x0a, 0x0a, 0x43, 0x61, 0x70, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, + 0x6d, 0x73, 0x22, 0x78, 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, + 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x12, 0x20, 0x0a, 0x0b, + 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1c, + 0x0a, 0x09, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, + 0x09, 0x52, 0x09, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x22, 0x3a, 0x0a, 0x08, + 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6b, 0x69, 0x6e, 0x64, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x12, 0x1a, 0x0a, 0x08, + 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, + 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 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, diff --git a/api/dwn/v1/state.cosmos_orm.go b/api/dwn/v1/state.cosmos_orm.go new file mode 100644 index 000000000..5eff57db7 --- /dev/null +++ b/api/dwn/v1/state.cosmos_orm.go @@ -0,0 +1,292 @@ +// 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, id []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, id []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 = CredentialIdIndexKey + +type CredentialIdIndexKey struct { + vs []interface{} +} + +func (x CredentialIdIndexKey) id() uint32 { return 0 } +func (x CredentialIdIndexKey) values() []interface{} { return x.vs } +func (x CredentialIdIndexKey) credentialIndexKey() {} + +func (this CredentialIdIndexKey) WithId(id []byte) CredentialIdIndexKey { + this.vs = []interface{}{id} + 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, id []byte) (found bool, err error) { + return this.table.PrimaryKey().Has(ctx, id) +} + +func (this credentialTable) Get(ctx context.Context, id []byte) (*Credential, error) { + var credential Credential + found, err := this.table.PrimaryKey().Get(ctx, &credential, id) + 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 58b193c4f..57b079fcd 100644 --- a/api/dwn/v1/state.pulsar.go +++ b/api/dwn/v1/state.pulsar.go @@ -62,7 +62,7 @@ func (x *_Credential_3_list) IsValid() bool { var ( md_Credential protoreflect.MessageDescriptor fd_Credential_id protoreflect.FieldDescriptor - fd_Credential_type protoreflect.FieldDescriptor + fd_Credential_kind protoreflect.FieldDescriptor fd_Credential_transports protoreflect.FieldDescriptor fd_Credential_public_key protoreflect.FieldDescriptor fd_Credential_attestation_type protoreflect.FieldDescriptor @@ -73,7 +73,7 @@ func init() { file_dwn_v1_state_proto_init() md_Credential = File_dwn_v1_state_proto.Messages().ByName("Credential") fd_Credential_id = md_Credential.Fields().ByName("id") - fd_Credential_type = md_Credential.Fields().ByName("type") + fd_Credential_kind = md_Credential.Fields().ByName("kind") 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") @@ -151,9 +151,9 @@ func (x *fastReflection_Credential) Range(f func(protoreflect.FieldDescriptor, p return } } - if x.Type_ != "" { - value := protoreflect.ValueOfString(x.Type_) - if !f(fd_Credential_type, value) { + if x.Kind != "" { + value := protoreflect.ValueOfString(x.Kind) + if !f(fd_Credential_kind, value) { return } } @@ -198,8 +198,8 @@ func (x *fastReflection_Credential) Has(fd protoreflect.FieldDescriptor) bool { switch fd.FullName() { case "dwn.v1.Credential.id": return len(x.Id) != 0 - case "dwn.v1.Credential.type": - return x.Type_ != "" + case "dwn.v1.Credential.kind": + return x.Kind != "" case "dwn.v1.Credential.transports": return len(x.Transports) != 0 case "dwn.v1.Credential.public_key": @@ -226,8 +226,8 @@ func (x *fastReflection_Credential) Clear(fd protoreflect.FieldDescriptor) { switch fd.FullName() { case "dwn.v1.Credential.id": x.Id = nil - case "dwn.v1.Credential.type": - x.Type_ = "" + case "dwn.v1.Credential.kind": + x.Kind = "" case "dwn.v1.Credential.transports": x.Transports = nil case "dwn.v1.Credential.public_key": @@ -255,8 +255,8 @@ func (x *fastReflection_Credential) Get(descriptor protoreflect.FieldDescriptor) case "dwn.v1.Credential.id": value := x.Id return protoreflect.ValueOfBytes(value) - case "dwn.v1.Credential.type": - value := x.Type_ + case "dwn.v1.Credential.kind": + value := x.Kind return protoreflect.ValueOfString(value) case "dwn.v1.Credential.transports": if len(x.Transports) == 0 { @@ -295,8 +295,8 @@ func (x *fastReflection_Credential) Set(fd protoreflect.FieldDescriptor, value p switch fd.FullName() { case "dwn.v1.Credential.id": x.Id = value.Bytes() - case "dwn.v1.Credential.type": - x.Type_ = value.Interface().(string) + case "dwn.v1.Credential.kind": + x.Kind = value.Interface().(string) case "dwn.v1.Credential.transports": lv := value.List() clv := lv.(*_Credential_3_list) @@ -335,8 +335,8 @@ func (x *fastReflection_Credential) Mutable(fd protoreflect.FieldDescriptor) pro 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.kind": + panic(fmt.Errorf("field kind 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": @@ -358,7 +358,7 @@ func (x *fastReflection_Credential) NewField(fd protoreflect.FieldDescriptor) pr switch fd.FullName() { case "dwn.v1.Credential.id": return protoreflect.ValueOfBytes(nil) - case "dwn.v1.Credential.type": + case "dwn.v1.Credential.kind": return protoreflect.ValueOfString("") case "dwn.v1.Credential.transports": list := []string{} @@ -442,7 +442,7 @@ func (x *fastReflection_Credential) ProtoMethods() *protoiface.Methods { if l > 0 { n += 1 + l + runtime.Sov(uint64(l)) } - l = len(x.Type_) + l = len(x.Kind) if l > 0 { n += 1 + l + runtime.Sov(uint64(l)) } @@ -520,10 +520,10 @@ func (x *fastReflection_Credential) ProtoMethods() *protoiface.Methods { 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_))) + if len(x.Kind) > 0 { + i -= len(x.Kind) + copy(dAtA[i:], x.Kind) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Kind))) i-- dAtA[i] = 0x12 } @@ -619,7 +619,7 @@ func (x *fastReflection_Credential) ProtoMethods() *protoiface.Methods { iNdEx = postIndex case 2: if wireType != 2 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Type_", wireType) + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Kind", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -647,7 +647,7 @@ func (x *fastReflection_Credential) ProtoMethods() *protoiface.Methods { if postIndex > l { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF } - x.Type_ = string(dAtA[iNdEx:postIndex]) + x.Kind = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 3: if wireType != 2 { @@ -1290,7 +1290,7 @@ type Credential struct { unknownFields protoimpl.UnknownFields 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") + Kind string `protobuf:"bytes,2,opt,name=kind,proto3" json:"kind,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) @@ -1324,9 +1324,9 @@ func (x *Credential) GetId() []byte { return nil } -func (x *Credential) GetType_() string { +func (x *Credential) GetKind() string { if x != nil { - return x.Type_ + return x.Kind } return "" } @@ -1408,10 +1408,10 @@ 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, 0xd3, 0x01, 0x0a, 0x0a, 0x43, 0x72, 0x65, 0x64, 0x65, 0x6e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xc9, 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, + 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x04, 0x6b, 0x69, 0x6e, 0x64, 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, @@ -1420,22 +1420,22 @@ var file_dwn_v1_state_proto_rawDesc = []byte{ 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, + 0x74, 0x3a, 0x0e, 0xf2, 0x9e, 0xd3, 0x8e, 0x03, 0x08, 0x0a, 0x04, 0x0a, 0x02, 0x69, 0x64, 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/proto/dwn/v1/genesis.proto b/proto/dwn/v1/genesis.proto index 86bce0067..5e5a5306d 100644 --- a/proto/dwn/v1/genesis.proto +++ b/proto/dwn/v1/genesis.proto @@ -26,13 +26,15 @@ message Params { // Capability reprensents the available capabilities of a decentralized web node message Capability { string name = 1; - string description = 2; + string parent = 2; + string description = 3; + repeated string resources = 4; } // Resource reprensents the available resources of a decentralized web node message Resource { - string name = 1; - string description = 2; + string kind = 1; + string template = 2; } // Schema is the Database Model for Decentralized Web Nodes diff --git a/proto/dwn/v1/state.proto b/proto/dwn/v1/state.proto index 0ac1efe51..00b865640 100644 --- a/proto/dwn/v1/state.proto +++ b/proto/dwn/v1/state.proto @@ -11,11 +11,10 @@ message Credential { option (cosmos.orm.v1.table) = { id: 1; primary_key: { fields: "id" } - index: { id: 1 fields: "type" } }; bytes id = 1; // The credential ID as a byte array - string type = 2; // The credential type (e.g. "public-key") + string kind = 2; // The credential type (e.g. "public-key") repeated string transports = 3; // Optional transport hints (usb, nfc, ble, internal) bytes public_key = 4; // The credential's public key string attestation_type = 5; // The attestation type used (e.g. "none", "indirect", etc) diff --git a/x/dwn/keeper/keeper.go b/x/dwn/keeper/keeper.go index 363ca49bf..0357613c1 100644 --- a/x/dwn/keeper/keeper.go +++ b/x/dwn/keeper/keeper.go @@ -81,7 +81,6 @@ func (k Keeper) Logger() log.Logger { // InitGenesis initializes the module's state from a genesis state. func (k *Keeper) InitGenesis(ctx context.Context, data *types.GenesisState) error { - if err := data.Params.Validate(); err != nil { return err } diff --git a/x/dwn/types/genesis.go b/x/dwn/types/genesis.go index e1e8ab313..58200b59f 100644 --- a/x/dwn/types/genesis.go +++ b/x/dwn/types/genesis.go @@ -1,5 +1,36 @@ package types +// Define capability hierarchy for smart account operations +const ( + // Root capabilities + CAP_OWNER = "OWNER" // Full account control + CAP_OPERATOR = "OPERATOR" // Can perform operations + CAP_OBSERVER = "OBSERVER" // Can view account state + + // Operation capabilities + CAP_EXECUTE = "EXECUTE" // Can execute transactions + CAP_PROPOSE = "PROPOSE" // Can propose transactions + CAP_SIGN = "SIGN" // Can sign transactions + + // Policy capabilities + CAP_SET_POLICY = "SET_POLICY" // Can modify account policies + CAP_SET_THRESHOLD = "SET_THRESHOLD" // Can modify signing threshold + + // Recovery capabilities + CAP_RECOVER = "RECOVER" // Can initiate recovery + CAP_SOCIAL = "SOCIAL" // Can act as social recovery +) + +// Resource types for smart account operations +type ResourceType string + +const ( + RES_ACCOUNT = "account" + RES_TRANSACTION = "tx" + RES_POLICY = "policy" + RES_RECOVERY = "recovery" +) + // DefaultIndex is the default global index const DefaultIndex uint64 = 1 diff --git a/x/dwn/types/genesis.pb.go b/x/dwn/types/genesis.pb.go index 969bc9fc8..2a34727a0 100644 --- a/x/dwn/types/genesis.pb.go +++ b/x/dwn/types/genesis.pb.go @@ -132,8 +132,10 @@ func (m *Params) GetSchema() *Schema { // 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"` + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + Parent string `protobuf:"bytes,2,opt,name=parent,proto3" json:"parent,omitempty"` + Description string `protobuf:"bytes,3,opt,name=description,proto3" json:"description,omitempty"` + Resources []string `protobuf:"bytes,4,rep,name=resources,proto3" json:"resources,omitempty"` } func (m *Capability) Reset() { *m = Capability{} } @@ -176,6 +178,13 @@ func (m *Capability) GetName() string { return "" } +func (m *Capability) GetParent() string { + if m != nil { + return m.Parent + } + return "" +} + func (m *Capability) GetDescription() string { if m != nil { return m.Description @@ -183,10 +192,17 @@ func (m *Capability) GetDescription() string { return "" } +func (m *Capability) GetResources() []string { + if m != nil { + return m.Resources + } + return nil +} + // 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"` + Kind string `protobuf:"bytes,1,opt,name=kind,proto3" json:"kind,omitempty"` + Template string `protobuf:"bytes,2,opt,name=template,proto3" json:"template,omitempty"` } func (m *Resource) Reset() { *m = Resource{} } @@ -222,16 +238,16 @@ func (m *Resource) XXX_DiscardUnknown() { var xxx_messageInfo_Resource proto.InternalMessageInfo -func (m *Resource) GetName() string { +func (m *Resource) GetKind() string { if m != nil { - return m.Name + return m.Kind } return "" } -func (m *Resource) GetDescription() string { +func (m *Resource) GetTemplate() string { if m != nil { - return m.Description + return m.Template } return "" } @@ -364,37 +380,40 @@ func init() { func init() { proto.RegisterFile("dwn/v1/genesis.proto", fileDescriptor_8e7492a25d5871dc) } var fileDescriptor_8e7492a25d5871dc = []byte{ - // 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,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c, 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, + // 519 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x54, 0x93, 0x31, 0x6f, 0x13, 0x31, + 0x14, 0xc7, 0x73, 0x34, 0xbd, 0xe6, 0x5e, 0x2b, 0x04, 0x56, 0x85, 0x4c, 0x84, 0x2e, 0x51, 0x06, + 0x54, 0x21, 0x94, 0x53, 0x61, 0xab, 0xb2, 0x50, 0x84, 0x58, 0xd1, 0x75, 0x63, 0x89, 0x9c, 0xbb, + 0xd7, 0x8b, 0x9b, 0x3b, 0xfb, 0x64, 0x3b, 0x49, 0xf3, 0x15, 0x98, 0x18, 0x19, 0x3b, 0x33, 0xf1, + 0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xe0, + 0x0c, 0x57, 0x7a, 0xca, 0x14, 0xd2, 0xc8, 0x2f, 0xb8, 0xd5, 0x36, 0x7b, 0xad, 0xe4, 0x25, 0x2f, + 0x91, 0x82, 0xcf, 0xde, 0xc8, 0xf3, 0xd1, 0xed, 0x3a, 0x0e, 0xee, 0xd6, 0x71, 0xf0, 0x73, 0x1d, + 0x07, 0x9f, 0x37, 0x71, 0xeb, 0x6e, 0x13, 0xb7, 0xbe, 0x6f, 0xe2, 0xd6, 0xc7, 0x41, 0xc1, 0xcd, + 0x74, 0x3e, 0x19, 0x66, 0xb2, 0x4a, 0xa4, 0xd0, 0x52, 0xa8, 0xc4, 0x1d, 0xd7, 0x89, 0xfd, 0x2a, + 0xcc, 0xaa, 0x46, 0x3d, 0x09, 0xdd, 0x1f, 0xfc, 0xf5, 0xdf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x9d, + 0x36, 0x1c, 0x5c, 0x29, 0x03, 0x00, 0x00, } func (this *Params) Equal(that interface{}) bool { @@ -535,11 +554,27 @@ func (m *Capability) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.Resources) > 0 { + for iNdEx := len(m.Resources) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Resources[iNdEx]) + copy(dAtA[i:], m.Resources[iNdEx]) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.Resources[iNdEx]))) + i-- + dAtA[i] = 0x22 + } + } 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] = 0x1a + } + if len(m.Parent) > 0 { + i -= len(m.Parent) + copy(dAtA[i:], m.Parent) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.Parent))) + i-- dAtA[i] = 0x12 } if len(m.Name) > 0 { @@ -572,17 +607,17 @@ func (m *Resource) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = 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))) + if len(m.Template) > 0 { + i -= len(m.Template) + copy(dAtA[i:], m.Template) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.Template))) 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))) + if len(m.Kind) > 0 { + i -= len(m.Kind) + copy(dAtA[i:], m.Kind) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.Kind))) i-- dAtA[i] = 0xa } @@ -731,10 +766,20 @@ func (m *Capability) Size() (n int) { if l > 0 { n += 1 + l + sovGenesis(uint64(l)) } + l = len(m.Parent) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } l = len(m.Description) if l > 0 { n += 1 + l + sovGenesis(uint64(l)) } + if len(m.Resources) > 0 { + for _, s := range m.Resources { + l = len(s) + n += 1 + l + sovGenesis(uint64(l)) + } + } return n } @@ -744,11 +789,11 @@ func (m *Resource) Size() (n int) { } var l int _ = l - l = len(m.Name) + l = len(m.Kind) if l > 0 { n += 1 + l + sovGenesis(uint64(l)) } - l = len(m.Description) + l = len(m.Template) if l > 0 { n += 1 + l + sovGenesis(uint64(l)) } @@ -1080,6 +1125,38 @@ func (m *Capability) Unmarshal(dAtA []byte) error { m.Name = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Parent", 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.Parent = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType) } @@ -1111,6 +1188,38 @@ func (m *Capability) Unmarshal(dAtA []byte) error { } m.Description = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Resources", 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.Resources = append(m.Resources, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) @@ -1163,7 +1272,7 @@ func (m *Resource) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Kind", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1191,11 +1300,11 @@ func (m *Resource) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Name = string(dAtA[iNdEx:postIndex]) + m.Kind = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Template", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1223,7 +1332,7 @@ func (m *Resource) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Description = string(dAtA[iNdEx:postIndex]) + m.Template = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex diff --git a/x/dwn/types/state.pb.go b/x/dwn/types/state.pb.go index d84aba9ef..f139d28cc 100644 --- a/x/dwn/types/state.pb.go +++ b/x/dwn/types/state.pb.go @@ -25,7 +25,7 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type Credential struct { Id []byte `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - Type string `protobuf:"bytes,2,opt,name=type,proto3" json:"type,omitempty"` + Kind string `protobuf:"bytes,2,opt,name=kind,proto3" json:"kind,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"` @@ -72,9 +72,9 @@ func (m *Credential) GetId() []byte { return nil } -func (m *Credential) GetType() string { +func (m *Credential) GetKind() string { if m != nil { - return m.Type + return m.Kind } return "" } @@ -167,29 +167,29 @@ func init() { func init() { proto.RegisterFile("dwn/v1/state.proto", fileDescriptor_040a9b061177db90) } var fileDescriptor_040a9b061177db90 = []byte{ - // 342 bytes of a gzipped FileDescriptorProto + // 339 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, 0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 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, + 0x14, 0x86, 0xeb, 0x34, 0x37, 0xbd, 0x39, 0xba, 0xea, 0xad, 0x3c, 0x80, 0x41, 0x22, 0x44, 0x9d, + 0xc2, 0xd2, 0xa8, 0x62, 0xab, 0x58, 0x80, 0x91, 0x05, 0x45, 0x4c, 0x08, 0xa9, 0x72, 0x13, 0x03, + 0x56, 0x1b, 0x3b, 0x72, 0x4e, 0x5b, 0xf2, 0x12, 0x88, 0x27, 0xe0, 0x79, 0x60, 0xab, 0xc4, 0xc2, + 0x88, 0xda, 0x37, 0xe0, 0x09, 0x50, 0xdc, 0x16, 0x75, 0xb1, 0x7c, 0x3e, 0xff, 0xfe, 0x74, 0x8e, + 0x0d, 0x34, 0x9b, 0xab, 0x78, 0xd6, 0x8f, 0x4b, 0xe4, 0x28, 0x7a, 0x85, 0xd1, 0xa8, 0xa9, 0x97, + 0xcd, 0x55, 0x6f, 0xd6, 0x3f, 0xdc, 0x4f, 0x75, 0x99, 0xeb, 0x32, 0xd6, 0x26, 0xaf, 0x23, 0xda, + 0xe4, 0xeb, 0x40, 0xf7, 0x9d, 0x00, 0x5c, 0x1a, 0x91, 0x09, 0x85, 0x92, 0x4f, 0x68, 0x1b, 0x1c, + 0x99, 0x31, 0x12, 0x92, 0xe8, 0x5f, 0xe2, 0xc8, 0x8c, 0x52, 0x70, 0xc7, 0x52, 0x65, 0xcc, 0x09, + 0x49, 0xe4, 0x27, 0x76, 0x4f, 0x03, 0x00, 0x34, 0x5c, 0x95, 0x85, 0x36, 0x58, 0xb2, 0x66, 0xd8, + 0x8c, 0xfc, 0x64, 0x87, 0xd0, 0x23, 0x80, 0x62, 0x3a, 0x9a, 0xc8, 0x74, 0x38, 0x16, 0x15, 0x73, + 0xad, 0xcb, 0x5f, 0x93, 0x2b, 0x51, 0xd1, 0x13, 0xe8, 0x70, 0x44, 0x51, 0x77, 0x29, 0xb5, 0x1a, + 0x62, 0x55, 0x08, 0xf6, 0xc7, 0xea, 0xff, 0xef, 0xf0, 0x9b, 0xaa, 0x10, 0xb5, 0x29, 0x35, 0x82, + 0xa3, 0xc8, 0x86, 0x1c, 0x99, 0x17, 0x92, 0xc8, 0x4d, 0xfc, 0x0d, 0x39, 0xc7, 0x41, 0xfb, 0xfb, + 0xf5, 0xe3, 0xb9, 0xf9, 0x17, 0xdc, 0x75, 0xd3, 0xdd, 0x3b, 0x68, 0x5d, 0x1b, 0x7d, 0x2f, 0x27, + 0x82, 0x32, 0x68, 0xf1, 0x34, 0xd5, 0x53, 0x85, 0x9b, 0x61, 0xb6, 0x25, 0xdd, 0x03, 0x8f, 0xe7, + 0xf6, 0xc0, 0xb1, 0xbe, 0x4d, 0x35, 0x38, 0xb6, 0xb2, 0x03, 0xf0, 0x7f, 0x6f, 0x52, 0xd8, 0x46, + 0x3b, 0x84, 0x39, 0x17, 0x67, 0x6f, 0xcb, 0x80, 0x2c, 0x96, 0x01, 0xf9, 0x5a, 0x06, 0xe4, 0x65, + 0x15, 0x34, 0x16, 0xab, 0xa0, 0xf1, 0xb9, 0x0a, 0x1a, 0xb7, 0xdd, 0x07, 0x89, 0x8f, 0xd3, 0x51, + 0x2f, 0xd5, 0x79, 0xac, 0x55, 0xa9, 0x95, 0x89, 0xed, 0xf2, 0x14, 0xd7, 0x3f, 0x52, 0x0f, 0x58, + 0x8e, 0x3c, 0xfb, 0xdc, 0xa7, 0x3f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x45, 0xf1, 0xed, 0xf9, 0xa5, + 0x01, 0x00, 0x00, } func (m *Credential) Marshal() (dAtA []byte, err error) { @@ -240,10 +240,10 @@ func (m *Credential) MarshalToSizedBuffer(dAtA []byte) (int, error) { 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))) + if len(m.Kind) > 0 { + i -= len(m.Kind) + copy(dAtA[i:], m.Kind) + i = encodeVarintState(dAtA, i, uint64(len(m.Kind))) i-- dAtA[i] = 0x12 } @@ -313,7 +313,7 @@ func (m *Credential) Size() (n int) { if l > 0 { n += 1 + l + sovState(uint64(l)) } - l = len(m.Type) + l = len(m.Kind) if l > 0 { n += 1 + l + sovState(uint64(l)) } @@ -424,7 +424,7 @@ func (m *Credential) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Type", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Kind", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -452,7 +452,7 @@ func (m *Credential) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Type = string(dAtA[iNdEx:postIndex]) + m.Kind = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 3: if wireType != 2 {