feat: add fast reflection methods for Capability and Resource

This commit is contained in:
Prad Nukala
2024-11-26 13:23:44 -05:00
parent 7a8707e5d0
commit 4a8a15e4d6
14 changed files with 3010 additions and 483 deletions
+477 -29
View File
@@ -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
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d, 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, 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, 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
+257 -39
View File
@@ -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, 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a, 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
}