| Code Coverage
| Lines | Functions and Methods | Classes and Traits
Total | 0.00% covered (danger) | 0.00% | 0 / 58 | 0.00% covered (danger) | 0.00% | 0 / 3 | CRAP | 0.00% covered (danger) | 0.00% | 0 / 1
CreateReverseInstruction | 0.00% covered (danger) | 0.00% | 0 / 58 | 0.00% covered (danger) | 0.00% | 0 / 3 | 30 | 0.00% covered (danger) | 0.00% | 0 / 1
__construct | 0.00% covered (danger) | 0.00% | 0 / 2 | 0.00% covered (danger) | 0.00% | 0 / 1 | 2 |
serialize | 0.00% covered (danger) | 0.00% | 0 / 1 | 0.00% covered (danger) | 0.00% | 0 / 1 | 2 |
getInstruction | 0.00% covered (danger) | 0.00% | 0 / 55 | 0.00% covered (danger) | 0.00% | 0 / 1 | 12 |

1 | <?php
2 |
3 | namespace Attestto\SolanaPhpSdk\Programs;
4 |
5 | use Attestto\SolanaPhpSdk\Buffer;
6 | use Attestto\SolanaPhpSdk\PublicKey;
7 | use Attestto\SolanaPhpSdk\TransactionInstruction;
8 | use Attestto\SolanaPhpSdk\Borsh\Borsh;
9 |
10 | class CreateReverseInstruction {
11 | public $tag;
12 | public $name;
13 |
14 | public const SCHEMA = [
15 | 'struct' => [
16 | 'tag' => 'u8',
17 | 'name' => 'string',
18 | ],
19 | ];
20 |
21 | public function __construct(array $obj) {
22 | $this->tag = 12;
23 | $this->name = $obj['name'];
24 | }
25 |
26 | public function serialize(): Buffer {
27 | return Borsh::serialize(self::SCHEMA, $this);
28 | }
29 |
30 | public function getInstruction(
31 | PublicKey $programId,
32 | PublicKey $namingServiceProgram,
33 | PublicKey $rootDomain,
34 | PublicKey $reverseLookup,
35 | PublicKey $systemProgram,
36 | PublicKey $centralState,
37 | PublicKey $feePayer,
38 | PublicKey $rentSysvar,
39 | ?PublicKey $parentName = null,
40 | ?PublicKey $parentNameOwner = null
41 | ): TransactionInstruction {
42 | $data = $this->serialize();
43 | $keys = [
44 | [
45 | 'pubkey' => $namingServiceProgram,
46 | 'isSigner' => false,
47 | 'isWritable' => false,
48 | ],
49 | [
50 | 'pubkey' => $rootDomain,
51 | 'isSigner' => false,
52 | 'isWritable' => false,
53 | ],
54 | [
55 | 'pubkey' => $reverseLookup,
56 | 'isSigner' => false,
57 | 'isWritable' => true,
58 | ],
59 | [
60 | 'pubkey' => $systemProgram,
61 | 'isSigner' => false,
62 | 'isWritable' => false,
63 | ],
64 | [
65 | 'pubkey' => $centralState,
66 | 'isSigner' => false,
67 | 'isWritable' => false,
68 | ],
69 | [
70 | 'pubkey' => $feePayer,
71 | 'isSigner' => true,
72 | 'isWritable' => true,
73 | ],
74 | [
75 | 'pubkey' => $rentSysvar,
76 | 'isSigner' => false,
77 | 'isWritable' => false,
78 | ],
79 | ];
80 |
81 | if (!is_null($parentName)) {
82 | $keys[] = [
83 | 'pubkey' => $parentName,
84 | 'isSigner' => false,
85 | 'isWritable' => true,
86 | ];
87 | }
88 |
89 | if (!is_null($parentNameOwner)) {
90 | $keys[] = [
91 | 'pubkey' => $parentNameOwner,
92 | 'isSigner' => true,
93 | 'isWritable' => true,
94 | ];
95 | }
96 |
97 | return new TransactionInstruction([
98 | 'keys' => $keys,
99 | 'programId' => $programId,
100 | 'data' => $data,
101 | ]);
102 | }
103 | }
104 |
105 | ?>