Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 92 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
| CreateWithNftInstruction | |
0.00% |
0 / 92 |
|
0.00% |
0 / 3 |
12 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
| serialize | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getInstruction | |
0.00% |
0 / 88 |
|
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 CreateWithNftInstruction { |
| 9 | public $tag; |
| 10 | public $name; |
| 11 | public $space; |
| 12 | |
| 13 | public const SCHEMA = [ |
| 14 | 'struct' => [ |
| 15 | 'tag' => 'u8', |
| 16 | 'name' => 'string', |
| 17 | 'space' => 'u32', |
| 18 | ], |
| 19 | ]; |
| 20 | |
| 21 | public function __construct(array $obj) { |
| 22 | $this->tag = 17; |
| 23 | $this->name = $obj['name']; |
| 24 | $this->space = $obj['space']; |
| 25 | } |
| 26 | |
| 27 | public function serialize(): Buffer { |
| 28 | return Borsh::serialize(self::SCHEMA, $this); |
| 29 | } |
| 30 | |
| 31 | public function getInstruction( |
| 32 | PublicKey $programId, |
| 33 | PublicKey $namingServiceProgram, |
| 34 | PublicKey $rootDomain, |
| 35 | PublicKey $name, |
| 36 | PublicKey $reverseLookup, |
| 37 | PublicKey $systemProgram, |
| 38 | PublicKey $centralState, |
| 39 | PublicKey $buyer, |
| 40 | PublicKey $nftSource, |
| 41 | PublicKey $nftMetadata, |
| 42 | PublicKey $nftMint, |
| 43 | PublicKey $masterEdition, |
| 44 | PublicKey $collection, |
| 45 | PublicKey $splTokenProgram, |
| 46 | PublicKey $rentSysvar, |
| 47 | PublicKey $state, |
| 48 | PublicKey $mplTokenMetadata |
| 49 | ): TransactionInstruction { |
| 50 | $data = $this->serialize(); |
| 51 | $keys = [ |
| 52 | [ |
| 53 | 'pubkey' => $namingServiceProgram, |
| 54 | 'isSigner' => false, |
| 55 | 'isWritable' => false, |
| 56 | ], |
| 57 | [ |
| 58 | 'pubkey' => $rootDomain, |
| 59 | 'isSigner' => false, |
| 60 | 'isWritable' => false, |
| 61 | ], |
| 62 | [ |
| 63 | 'pubkey' => $name, |
| 64 | 'isSigner' => false, |
| 65 | 'isWritable' => true, |
| 66 | ], |
| 67 | [ |
| 68 | 'pubkey' => $reverseLookup, |
| 69 | 'isSigner' => false, |
| 70 | 'isWritable' => true, |
| 71 | ], |
| 72 | [ |
| 73 | 'pubkey' => $systemProgram, |
| 74 | 'isSigner' => false, |
| 75 | 'isWritable' => false, |
| 76 | ], |
| 77 | [ |
| 78 | 'pubkey' => $centralState, |
| 79 | 'isSigner' => false, |
| 80 | 'isWritable' => false, |
| 81 | ], |
| 82 | [ |
| 83 | 'pubkey' => $buyer, |
| 84 | 'isSigner' => true, |
| 85 | 'isWritable' => true, |
| 86 | ], |
| 87 | [ |
| 88 | 'pubkey' => $nftSource, |
| 89 | 'isSigner' => false, |
| 90 | 'isWritable' => true, |
| 91 | ], |
| 92 | [ |
| 93 | 'pubkey' => $nftMetadata, |
| 94 | 'isSigner' => false, |
| 95 | 'isWritable' => true, |
| 96 | ], |
| 97 | [ |
| 98 | 'pubkey' => $nftMint, |
| 99 | 'isSigner' => false, |
| 100 | 'isWritable' => true, |
| 101 | ], |
| 102 | [ |
| 103 | 'pubkey' => $masterEdition, |
| 104 | 'isSigner' => false, |
| 105 | 'isWritable' => true, |
| 106 | ], |
| 107 | [ |
| 108 | 'pubkey' => $collection, |
| 109 | 'isSigner' => false, |
| 110 | 'isWritable' => true, |
| 111 | ], |
| 112 | [ |
| 113 | 'pubkey' => $splTokenProgram, |
| 114 | 'isSigner' => false, |
| 115 | 'isWritable' => false, |
| 116 | ], |
| 117 | [ |
| 118 | 'pubkey' => $rentSysvar, |
| 119 | 'isSigner' => false, |
| 120 | 'isWritable' => false, |
| 121 | ], |
| 122 | [ |
| 123 | 'pubkey' => $state, |
| 124 | 'isSigner' => false, |
| 125 | 'isWritable' => false, |
| 126 | ], |
| 127 | [ |
| 128 | 'pubkey' => $mplTokenMetadata, |
| 129 | 'isSigner' => false, |
| 130 | 'isWritable' => false, |
| 131 | ], |
| 132 | ]; |
| 133 | |
| 134 | return new TransactionInstruction([ |
| 135 | 'keys' => $keys, |
| 136 | 'programId' => $programId, |
| 137 | 'data' => $data, |
| 138 | ]); |
| 139 | } |
| 140 | } |
| 141 | |
| 142 | ?> |