| Code Coverage
| Lines | Functions and Methods | Classes and Traits
Total | 0.00% covered (danger) | 0.00% | 0 / 30 | 0.00% covered (danger) | 0.00% | 0 / 3 | CRAP | 0.00% covered (danger) | 0.00% | 0 / 1
RegisterFavoriteInstruction | 0.00% covered (danger) | 0.00% | 0 / 30 | 0.00% covered (danger) | 0.00% | 0 / 3 | 12 | 0.00% covered (danger) | 0.00% | 0 / 1
__construct | 0.00% covered (danger) | 0.00% | 0 / 1 | 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 / 28 | 0.00% covered (danger) | 0.00% | 0 / 1 | 2 |

1 | <?php
2 |
3 | use Attestto\SolanaPhpSdk\Buffer;
4 | use Attestto\SolanaPhpSdk\PublicKey;
5 | use Attestto\SolanaPhpSdk\TransactionInstruction;
6 | use Attestto\SolanaPhpSdk\Borsh\Borsh;
7 |
8 | class RegisterFavoriteInstruction {
9 | public $tag;
10 |
11 | public const SCHEMA = [
12 | 'struct' => [
13 | 'tag' => 'u8',
14 | ],
15 | ];
16 |
17 | public function __construct() {
18 | $this->tag = 6;
19 | }
20 |
21 | public function serialize(): Buffer {
22 | return Borsh::serialize(self::SCHEMA, $this);
23 | }
24 |
25 | public function getInstruction(
26 | PublicKey $programId,
27 | PublicKey $nameAccount,
28 | PublicKey $favouriteAccount,
29 | PublicKey $owner,
30 | PublicKey $systemProgram
31 | ): TransactionInstruction {
32 | $data = $this->serialize();
33 | $keys = [
34 | [
35 | 'pubkey' => $nameAccount,
36 | 'isSigner' => false,
37 | 'isWritable' => false,
38 | ],
39 | [
40 | 'pubkey' => $favouriteAccount,
41 | 'isSigner' => false,
42 | 'isWritable' => true,
43 | ],
44 | [
45 | 'pubkey' => $owner,
46 | 'isSigner' => true,
47 | 'isWritable' => true,
48 | ],
49 | [
50 | 'pubkey' => $systemProgram,
51 | 'isSigner' => false,
52 | 'isWritable' => false,
53 | ],
54 | ];
55 |
56 | return new TransactionInstruction([
57 | 'keys' => $keys,
58 | 'programId' => $programId,
59 | 'data' => $data,
60 | ]);
61 | }
62 | }
63 |
64 | ?>