Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 33 |
|
0.00% |
0 / 6 |
CRAP | |
0.00% |
0 / 1 |
| NftRecord | |
0.00% |
0 / 33 |
|
0.00% |
0 / 6 |
72 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| deserialize | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| retrieve | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
12 | |||
| findKey | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 | |||
| getRecordFromMint | |
0.00% |
0 / 18 |
|
0.00% |
0 / 1 |
2 | |||
| getDomainMint | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace Attestto\SolanaPhpSdk\Programs\SNS; |
| 4 | |
| 5 | use Attestto\SolanaPhpSdk\PublicKey; |
| 6 | |
| 7 | |
| 8 | |
| 9 | class NftRecord |
| 10 | { |
| 11 | |
| 12 | |
| 13 | public function __construct($obj) |
| 14 | { |
| 15 | |
| 16 | } |
| 17 | |
| 18 | public static function deserialize($data) |
| 19 | { |
| 20 | return new NftRecord(deserialize(self::$schema, $data)); |
| 21 | } |
| 22 | |
| 23 | public static function retrieve($connection, $key) |
| 24 | { |
| 25 | $accountInfo = $connection->getAccountInfo($key); |
| 26 | if (!$accountInfo || !$accountInfo->data) { |
| 27 | throw new Exception("NFT record not found"); |
| 28 | } |
| 29 | return self::deserialize($accountInfo->data); |
| 30 | } |
| 31 | |
| 32 | public static function findKey($nameAccount, $programId) |
| 33 | { |
| 34 | return PublicKey::findProgramAddress( |
| 35 | [Buffer::from("nft_record"), $nameAccount->toBuffer()], |
| 36 | $programId |
| 37 | ); |
| 38 | } |
| 39 | |
| 40 | |
| 41 | function getRecordFromMint($connection, $mint) |
| 42 | { |
| 43 | $filters = [ |
| 44 | [ |
| 45 | 'memcmp' => [ |
| 46 | 'offset' => 0, |
| 47 | 'bytes' => '3', |
| 48 | ], |
| 49 | ], |
| 50 | [ |
| 51 | 'memcmp' => [ |
| 52 | 'offset' => 1 + 1 + 32 + 32, |
| 53 | 'bytes' => $mint->toBase58(), |
| 54 | ], |
| 55 | ], |
| 56 | ]; |
| 57 | |
| 58 | $result = $connection->getProgramAccounts(NAME_TOKENIZER_ID, [ |
| 59 | 'filters' => $filters, |
| 60 | ]); |
| 61 | |
| 62 | return $result; |
| 63 | } |
| 64 | |
| 65 | const NAME_TOKENIZER_ID = new PublicKey( |
| 66 | "nftD3vbNkNqfj2Sd3HZwbpw4BxxKWr4AjGb9X38JeZk" |
| 67 | ); |
| 68 | |
| 69 | const MINT_PREFIX = "tokenized_name"; |
| 70 | |
| 71 | function getDomainMint($domain) |
| 72 | { |
| 73 | $mint = PublicKey::findProgramAddressSync( |
| 74 | [MINT_PREFIX, $domain->toBuffer()], |
| 75 | NAME_TOKENIZER_ID |
| 76 | )[0]; |
| 77 | return $mint; |
| 78 | } |
| 79 | |
| 80 | //enum Tag { |
| 81 | // Uninitialized = 0, |
| 82 | // CentralState = 1, |
| 83 | // ActiveRecord = 2, |
| 84 | // InactiveRecord = 3, |
| 85 | //} |
| 86 | } |
| 87 | |
| 88 | |
| 89 |