Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
DidData
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 fromBuffer
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3namespace Attestto\SolanaPhpSdk\Accounts;
4
5use Attestto\SolanaPhpSdk\Accounts\Did\VerificationMethodStruct;
6use Attestto\SolanaPhpSdk\Accounts\Did\ServiceStruct;
7use Attestto\SolanaPhpSdk\Borsh\Borsh;
8use Attestto\SolanaPhpSdk\Borsh\BorshDeserializable;
9use Attestto\SolanaPhpSdk\Borsh\BorshObject;
10
11/**
12 * Class DidData
13 * 
14 * This class represents a Decentralized Identifier (DID) account.
15 * It provides methods for creating and managing DID accounts, signing and verifying messages, and other related operations.
16 * @version 1.0
17 * @package Attestto\SolanaPhpSdk\Accounts
18 * @license MIT
19 * @author Eduardo Chongkan
20 * @link https://chongkan.com
21 * @see https://github.com/identity-com/sol-did/tree/develop/sol-did/client/packages/idl
22 * @see https://explorer.solana.com/address/didso1Dpqpm4CsiCjzP766BGY89CAdD6ZBL68cRhFPc/anchor-program?cluster=devnet
23 */
24
25class DidData
26{
27
28    use BorshObject;
29    public $keyData;
30
31    public const SCHEMA = [
32        VerificationMethodStruct::class => VerificationMethodStruct::SCHEMA[VerificationMethodStruct::class],
33        ServiceStruct::class => ServiceStruct::SCHEMA[ServiceStruct::class],
34        self::class => [
35            'kind' => 'struct',
36            'fields' => [
37                ['offset', 'u64'],
38                ['version', 'u8'],
39                ['bump', 'u8'],
40                ['nonce', 'u64'],
41                ['initialVerificationMethod', 'string'],
42                ['flags', 'u16'],
43                ['methodType', 'u8'],
44                ['keyData', ['u8']],
45                ['verificationMethods', [VerificationMethodStruct::class]],
46                ['services', [ServiceStruct::class]],
47                ['nativeControllers', ['pubKey']],
48                ['otherControllers', ['string']],
49            ],
50        ],
51    ];
52
53    public static function fromBuffer(array $buffer): self
54    {
55        return Borsh::deserialize(self::SCHEMA, self::class, $buffer);
56    }
57}