Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 9
0.00% covered (danger)
0.00%
0 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
NameRegistryStateAccount
0.00% covered (danger)
0.00%
0 / 9
0.00% covered (danger)
0.00%
0 / 2
12
0.00% covered (danger)
0.00%
0 / 1
 retrieve
0.00% covered (danger)
0.00%
0 / 8
0.00% covered (danger)
0.00%
0 / 1
6
 deserialize
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
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\Connection;
10use Attestto\SolanaPhpSdk\PublicKey;
11use Attestto\SolanaPhpSdk\Exceptions\SNSError;
12
13
14/**
15 * Class DidData
16 * 
17 * This class represents a Decentralized Identifier (DID) account.
18 * It provides methods for creating and managing DID accounts, signing and verifying messages, and other related operations.
19 * @version 1.0
20 * @package Attestto\SolanaPhpSdk\Accounts
21 * @license MIT
22 * @author Eduardo Chongkan
23 * @link https://chongkan.com
24 * @see https://github.com/identity-com/sol-did/tree/develop/sol-did/client/packages/idl
25 * @see https://explorer.solana.com/address/didso1Dpqpm4CsiCjzP766BGY89CAdD6ZBL68cRhFPc/anchor-program?cluster=devnet
26 */
27
28class NameRegistryStateAccount
29{
30
31    use BorshDeserializable;
32
33
34    public const SCHEMA = [
35        self::class => [
36            'kind' => 'struct',
37            'fields' => [
38                ['parentName', ['u8']],
39                ['owner', ['u8']],
40                ['class', ['u8']]
41            ],
42        ],
43    ];
44
45    public static function retrieve(Connection $connection, PublicKey $nameAccountKey)
46    {
47        $nameAccount = $connection->getAccountInfo($nameAccountKey);
48        if (!$nameAccount) {
49            throw new SNSError(SNSError::AccountDoesNotExist);
50        }
51
52        $res = new NameRegistryStateAccount(
53            self::deserialize($nameAccount['data'])
54        );
55        //$res->data = $nameAccount->data->slice($this->config->SOL_RECORD_SIG_LEN);
56
57        $nftOwner = retrieveNftOwner($connection, $nameAccountKey);
58
59        return ['registry' => $res, 'nftOwner' => $nftOwner];
60    }
61
62    public static function deserialize(array $buffer): self
63    {
64        return Borsh::deserialize(self::SCHEMA, self::class, $buffer);
65    }
66}
67
68
69