| Code Coverage
| Lines | Functions and Methods | Classes and Traits
Total | 0.00% covered (danger) | 0.00% | 0 / 21 | 0.00% covered (danger) | 0.00% | 0 / 1 | CRAP | 0.00% covered (danger) | 0.00% | 0 / 1
SplSnsProgram | 0.00% covered (danger) | 0.00% | 0 / 21 | 0.00% covered (danger) | 0.00% | 0 / 1 | 2 | 0.00% covered (danger) | 0.00% | 0 / 1
getRecordFromMint | 0.00% covered (danger) | 0.00% | 0 / 21 | 0.00% covered (danger) | 0.00% | 0 / 1 | 2 |

1 | <?php
2 |
3 | namespace Attestto\SolanaPhpSdk\Programs;
4 |
5 | use Attestto\SolanaPhpSdk\Program;
6 | use Attestto\SolanaPhpSdk\Accounts\Sns\NtfRecordAccount;
7 | use Attestto\SolanaPhpSdk\PublicKey;
8 | use Attestto\SolanaPhpSdk\Connection;
9 | use StephenHill\Base58;
10 | use Attestto\SolanaPhpSdk\SolanaRpcClient;
11 | use Attestto\SolanaPhpSdk\TransactionInstruction;
12 | use Attestto\SolanaPhpSdk\Util\AccountMeta;
13 | use Attestto\SolanaPhpSdk\Util\Buffer;
14 |
15 | /**
16 | * Class DidSolProgram
17 | *
18 | * This class represents a program for interacting with the Solana blockchain using the DID (Decentralized Identifier) protocol.
19 | * It provides methods for creating and managing DID accounts, signing and verifying messages, and other related operations.
20 | * @version 1.0
21 | * @package Attestto\SolanaPhpSdk\
22 | * @license MIT
23 | * @author Eduardo Chongkan
24 | * @link https://chongkan.com
25 | * @see https://github.com/identity-com/sol-did
26 | */
27 |
28 | class SplSnsProgram extends Program
29 | {
30 | public const NAME_TOKENIZER_ID = 'nftD3vbNkNqfj2Sd3HZwbpw4BxxKWr4AjGb9X38JeZk';
31 |
32 | public const MINT_PREFIX = 'tokenized_name';
33 |
34 | // public function createSubDomain($subdomain) : TransactionInstruction {
35 | // $ix = new TransactionInstruction(
36 | // new PublicKey(self::DIDSOL_PROGRAM_ID),
37 | // [
38 | // new AccountMeta(new PublicKey($this->publicKey), true, true),
39 | // new AccountMeta(new PublicKey($this->publicKey), false, true),
40 | // ],
41 | // $subdomain
42 | // );
43 | // }
44 |
45 | // public static function retrieve(Connection $connection, PublicKey $key, $accountType): self
46 | // {
47 | // $accountInfo = $connection->getAccountInfo($key);
48 | // if (!$accountInfo || !$accountInfo['data']) {
49 | // throw new \Exception("NFT record not found");
50 | // }
51 | // $base64String = base64_decode($accountInfo['data']);
52 | // $uint8Array = array_values(unpack('C*', $base64String));
53 | // return self::deserialize($uint8Array);
54 | // }
55 |
56 | /**
57 | * This function can be used to retrieve a NFT Record given a mint
58 | *
59 | * @param connection A solana RPC connection
60 | * @param mint The mint of the NFT Record
61 | * @returns
62 | */
63 | public function getRecordFromMint(string $pubKey)
64 | {
65 | $magicOffsetNumber = 0;
66 |
67 | return $this->client->call('getProgramAccounts', [
68 | self::NAME_TOKENIZER_ID,
69 | [
70 | 'encoding' => 'base64',
71 | 'filters' => [
72 | [
73 | 'memcmp' => [
74 | 'bytes' => '3',
75 | 'offset' => $magicOffsetNumber,
76 | ],
77 | ],
78 | [
79 | 'memcmp' => [
80 | 'bytes' => $pubKey,
81 | 'offset' => 1 + 1 + 32 + 32,
82 | ],
83 | ],
84 | ],
85 | ],
86 | ]);
87 | }
88 |
89 |
90 |
91 | }