-
92.31% covered (success)
+
Connection.php |
+
+
+ 63.16% covered (warning)
|
-
92.31% |
-
24 / 26 |
+
63.16% |
+
24 / 38 |
-
- 77.78% covered (warning)
+
+ 70.00% covered (warning)
|
-
77.78% |
-
7 / 9 |
+
70.00% |
+
7 / 10 |
diff --git a/docs/SPL-Token-Program.md b/docs/SPL-Token-Program.md
new file mode 100644
index 0000000..c049d28
--- /dev/null
+++ b/docs/SPL-Token-Program.md
@@ -0,0 +1,4 @@
+# SPL-Token Program PHP-SDK Annotations & Usage
+
+## Instructions
+
diff --git a/docs/SplToken/SplTokenTest.php b/docs/SplToken/SplTokenTest.php
deleted file mode 100644
index 8383dc5..0000000
--- a/docs/SplToken/SplTokenTest.php
+++ /dev/null
@@ -1,59 +0,0 @@
-assembleClient('POST', []);
- $this->splTokenProgram = new SplTokenProgram($client);
- }
-
-// public function testGetAssociatedTokenAddressSync()
-// {
-// $mockMint = $this->createMock(PublicKey::class);
-// $mockOwner = $this->createMock(PublicKey::class);
-// $mockOwner->method('toBuffer')->willReturn('buffer');
-// $mockOwner->method('isOnCurve')->willReturn(true);
-//
-// $mockProgramId = 'programId';
-// $mockAssociatedTokenProgramId = 'associatedTokenProgramId';
-//
-// $result = $this->splToken->getAssociatedTokenAddressSync(
-// $mockMint,
-// $mockOwner,
-// false,
-// $mockProgramId,
-// $mockAssociatedTokenProgramId
-// );
-//
-// $this->assertInstanceOf(PublicKey::class, $result);
-// }
-//
-// public function testGetAssociatedTokenAddressSyncThrowsException()
-// {
-// $this->expectException(TokenOwnerOffCurveError::class);
-//
-// $mockMint = $this->createMock(PublicKey::class);
-// $mockOwner = $this->createMock(PublicKey::class);
-// $mockOwner->method('toBuffer')->willReturn('buffer');
-// $mockOwner->method('isOnCurve')->willReturn(false);
-//
-// $mockProgramId = 'programId';
-// $mockAssociatedTokenProgramId = 'associatedTokenProgramId';
-//
-// $this->splToken->getAssociatedTokenAddressSync(
-// $mockMint,
-// $mockOwner,
-// false,
-// $mockProgramId,
-// $mockAssociatedTokenProgramId
-// );
-// }
-}
\ No newline at end of file
diff --git a/docs/Web3-js.md b/docs/Web3-js.md
new file mode 100644
index 0000000..d16fd4a
--- /dev/null
+++ b/docs/Web3-js.md
@@ -0,0 +1,11 @@
+# Web3.js Solana SDK Annotations & Usage
+---------------
+
+## SPL Token Program
+
+ -- getOrCreateAssociatedTokenAccount (BE)
+
+## Vite Configuration
+
+
+
diff --git a/src/Accounts/README.md b/src/Accounts/README.md
new file mode 100644
index 0000000..6766fb1
--- /dev/null
+++ b/src/Accounts/README.md
@@ -0,0 +1 @@
+# Accounts == State
diff --git a/src/Accounts/Sns/NameRegistryStateAccount.php b/src/Accounts/Sns/NameRegistryStateAccount.php
deleted file mode 100644
index 9304ebb..0000000
--- a/src/Accounts/Sns/NameRegistryStateAccount.php
+++ /dev/null
@@ -1,69 +0,0 @@
- [
- 'kind' => 'struct',
- 'fields' => [
- ['parentName', ['u8']],
- ['owner', ['u8']],
- ['class', ['u8']]
- ],
- ],
- ];
-
- public static function retrieve(Connection $connection, PublicKey $nameAccountKey)
- {
- $nameAccount = $connection->getAccountInfo($nameAccountKey);
- if (!$nameAccount) {
- throw new SNSError(SNSError::AccountDoesNotExist);
- }
-
- $res = new NameRegistryStateAccount(
- self::deserialize($nameAccount['data'])
- );
- //$res->data = $nameAccount->data->slice($this->config->SOL_RECORD_SIG_LEN);
-
- $nftOwner = retrieveNftOwner($connection, $nameAccountKey);
-
- return ['registry' => $res, 'nftOwner' => $nftOwner];
- }
-
- public static function deserialize(array $buffer): self
- {
- return Borsh::deserialize(self::SCHEMA, self::class, $buffer);
- }
-}
-
-
-
diff --git a/src/Connection.php b/src/Connection.php
index 41457f5..e36daf6 100644
--- a/src/Connection.php
+++ b/src/Connection.php
@@ -149,5 +149,27 @@ public function requestAirdrop(array $params = []): string
return $response = $this->client->call('requestAirdrop', $params );
}
+ // https://solana.com/docs/rpc/http/getprogramaccounts
+ // https://sns.guide/domain-name/all-domains.html
+ public function getProgramAccounts(string $programIdBs58, $dataSlice, $filters)
+ {
+ $params = [
+ $programIdBs58,
+ [
+ 'dataSlice' => $dataSlice,
+ 'filters' => $filters,
+ 'dataSize' => 108, // 'dataSize' => 108
+ 'encoding' => 'base64',
+ 'page' => 1,
+ 'limit' => 1000
+
+ ],
+
+
+ ];
+ return $this->client->call('getProgramAccounts', $params );
+ //return $this->client->call('getAssetsByOwner', $params );
+
+ }
}
diff --git a/src/Interfaces/AccountKeyInterface.php b/src/Interfaces/AccountKeyInterface.php
deleted file mode 100644
index fe4e7e1..0000000
--- a/src/Interfaces/AccountKeyInterface.php
+++ /dev/null
@@ -1,11 +0,0 @@
-getDomainKeySync($subdomain);
+ $parent = $domainKeySync['parent'];
+ $pubkey = $domainKeySync['pubkey'];
+
+ $lamports = $connection->getMinimumBalanceForRentExemption(
+ $space + NameRegistryStateAccount::SOL_RECORD_SIG_LEN
+ );
+
+ $ix_create = $this->createNameRegistry(
+ $connection,
+ "\0" . $sub,
+ $space,
+ $feePayer ?? $owner,
+ $owner,
+ $lamports,
+ null,
+ $parent
+ );
+ $ixs[] = $ix_create;
+
+ $reverseKey = $this->getReverseKeySync($subdomain, true);
+ $info = $connection->getAccountInfo($reverseKey);
+ if (!$info['data']) {
+ $reverseName = $this->createReverseName(
+ $pubkey,
+ "\0" . $sub,
+ $feePayer ?? $owner,
+ $parent,
+ $owner
+ );
+ $ixs = array_merge($ixs, $reverseName[1]);
+ }
+
+ return [[], $ixs];
+ }
+}
diff --git a/config/SNS/Constants/config.json b/src/Programs/SNS/Constants/config.json
similarity index 100%
rename from config/SNS/Constants/config.json
rename to src/Programs/SNS/Constants/config.json
diff --git a/config/SNS/Constants/record.json b/src/Programs/SNS/Constants/record.json
similarity index 100%
rename from config/SNS/Constants/record.json
rename to src/Programs/SNS/Constants/record.json
diff --git a/config/SNS/Instructions.php b/src/Programs/SNS/Instructions/Instructions.php
similarity index 73%
rename from config/SNS/Instructions.php
rename to src/Programs/SNS/Instructions/Instructions.php
index 60cd87b..64d23a6 100644
--- a/config/SNS/Instructions.php
+++ b/src/Programs/SNS/Instructions/Instructions.php
@@ -1,59 +1,55 @@
length))->toBuffer(),
+ Buffer::fromArray([0]), // Create Instruction code 0
+ new Buffer(count($hashed_name), Buffer::TYPE_INT, false),
$hashed_name,
- $lamports->toBuffer(),
- $space->toBuffer()
+ $lamports,
+ $space
];
$data = Buffer::concat($buffers);
@@ -117,11 +113,11 @@ function createInstruction(
];
}
- return new TransactionInstruction([
- 'keys' => $keys,
- 'programId' => $nameProgramId,
- 'data' => $data
- ]);
+ return new TransactionInstruction(
+ new PublicKey($nameProgramId),
+ $keys,
+ $data
+ );
}
@@ -130,22 +126,23 @@ function createInstruction(
*
* @param PublicKey $nameProgramId The public key of the name program.
* @param PublicKey $nameAccountKey The public key of the name account.
- * @param Numberu32 $offset The offset.
+ * @param $offset The offset.
* @param Buffer $input_data The input data.
* @param PublicKey $nameUpdateSigner The public key of the name update signer.
* @return TransactionInstruction The created transaction instruction.
+ * @throws InputValidationException
*/
function updateInstruction(
PublicKey $nameProgramId,
PublicKey $nameAccountKey,
- Numberu32 $offset,
+ Buffer $offset,
Buffer $input_data,
PublicKey $nameUpdateSigner
): TransactionInstruction {
$buffers = [
Buffer::fromArray([1]),
- $offset->toBuffer(),
- (new Numberu32($input_data->length))->toBuffer(),
+ $offset,
+ new Buffer(count($input_data), Buffer::TYPE_INT, false),
$input_data
];
@@ -163,11 +160,11 @@ function updateInstruction(
]
];
- return new TransactionInstruction([
- 'keys' => $keys,
- 'programId' => $nameProgramId,
- 'data' => $data
- ]);
+ return new TransactionInstruction(
+ new PublicKey($nameProgramId),
+ $keys,
+ $data
+ );
}
@@ -182,6 +179,7 @@ function updateInstruction(
* @param PublicKey|null $nameParent The public key of the name parent.
* @param PublicKey|null $parentOwner The public key of the parent owner.
* @return TransactionInstruction The created transaction instruction.
+ * @throws InputValidationException
*/
function transferInstruction(
PublicKey $nameProgramId,
@@ -234,11 +232,11 @@ function transferInstruction(
];
}
- return new TransactionInstruction([
- 'keys' => $keys,
- 'programId' => $nameProgramId,
- 'data' => $data
- ]);
+ return new TransactionInstruction(
+ new PublicKey($nameProgramId),
+ $keys,
+ $data
+ );
}
@@ -250,8 +248,9 @@ function transferInstruction(
* @param PublicKey $payerKey The public key of the payer.
* @param PublicKey $nameAccountKey The public key of the name account.
* @param PublicKey $nameOwnerKey The public key of the name owner.
- * @param Numberu32 $space The amount of space.
+ * @param Buffer $space A Buffer instance that should represent a 32-bit unsigned integer.
* @return TransactionInstruction The created transaction instruction.
+ * @throws InputValidationException
*/
function reallocInstruction(
PublicKey $nameProgramId,
@@ -259,11 +258,11 @@ function reallocInstruction(
PublicKey $payerKey,
PublicKey $nameAccountKey,
PublicKey $nameOwnerKey,
- Numberu32 $space
+ Buffer $space
): TransactionInstruction {
$buffers = [
Buffer::fromArray([4]),
- $space->toBuffer()
+ $space
];
$data = Buffer::concat($buffers);
@@ -290,11 +289,11 @@ function reallocInstruction(
]
];
- return new TransactionInstruction([
- 'keys' => $keys,
- 'programId' => $nameProgramId,
- 'data' => $data
- ]);
+ return new TransactionInstruction(
+ new PublicKey($nameProgramId),
+ $keys,
+ $data
+ );
}
/**
@@ -335,11 +334,11 @@ function deleteInstruction(
]
];
- return new TransactionInstruction([
- 'keys' => $keys,
- 'programId' => $nameProgramId,
- 'data' => $data
- ]);
+ return new TransactionInstruction(
+ new PublicKey($nameProgramId),
+ $keys,
+ $data
+ );
}
diff --git a/src/Programs/SNS/State/NameRegistryStateAccount.php b/src/Programs/SNS/State/NameRegistryStateAccount.php
new file mode 100644
index 0000000..2b124a2
--- /dev/null
+++ b/src/Programs/SNS/State/NameRegistryStateAccount.php
@@ -0,0 +1,69 @@
+ [
+ 'kind' => 'struct',
+ 'fields' => [
+ ['parentName', 'pubkey'],
+ ['owner', 'pubkey'],
+ ['class', 'pubkey']
+ ],
+ ],
+ ];
+ const SOL_RECORD_SIG_LEN = 96; // HEADER_LEN
+
+ /**
+ * @throws SNSError
+ * @throws AccountNotFoundException
+ */
+ public static function retrieve(Connection $connection, string $nameAccountKey): array
+ {
+ $nameAccount = $connection->getAccountInfo($nameAccountKey);
+ if (!$nameAccount) {
+ throw new SNSError(SNSError::AccountDoesNotExist);
+ }
+
+ $base64String = base64_decode($nameAccount['data'][0]);
+ $uint8Array = array_values(unpack('C*', $base64String));
+ $dataBuffer = Buffer::from($base64String);
+
+ $res = NameRegistryStateAccount::deserialize($dataBuffer->toArray());
+
+ $res->data = $dataBuffer->slice(self::SOL_RECORD_SIG_LEN);
+ // TODO: Implement retrieveNftOwner
+ //$nftOwner = retrieveNftOwner($connection, $nameAccountKey);
+
+ return ['registry' => $res, 'nftOwner' => false];
+ }
+
+ public static function deserialize(array $buffer): self
+ {
+ return Borsh::deserialize(self::SCHEMA, self::class, $buffer);
+ }
+}
+
+
+
diff --git a/config/SNS/Deprecated/Utils.php b/src/Programs/SNS/Utils.php
similarity index 79%
rename from config/SNS/Deprecated/Utils.php
rename to src/Programs/SNS/Utils.php
index fbdc22e..e6344ba 100644
--- a/config/SNS/Deprecated/Utils.php
+++ b/src/Programs/SNS/Utils.php
@@ -1,21 +1,15 @@
config = $config;
- } else {
- $this->config = $this->loadConstants();
- }
- $sns_records_id = new PublicKey($this->config['BONFIDA_SNS_RECORDS_ID']);
-
- $this->centralStateSNSRecords = PublicKey::findProgramAddressSync(
- [$sns_records_id],
- $sns_records_id);
-
- return $this;
- }
private function loadConstants()
{
@@ -49,7 +28,7 @@ private function loadConstants()
public function getHashedNameSync(string $name): Buffer
{
$input = $this->config['HASH_PREFIX'] . $name;
- $hashed = hash('sha256', Buffer::from($input));
+ $hashed = hash('sha256', Buffer::from($input), true);
return Buffer::from($hashed);
}
@@ -59,7 +38,7 @@ public function getHashedNameSync(string $name): Buffer
* @param PublicKey|null $nameParent The name parent public key
* @return PublicKey The public key of the name account
* @throws InputValidationException
- * @deprecated Use {@link getNameAccountKeySync} instead
+ *
*/
public function getNameAccountKeySync(
Buffer $hashed_name,
@@ -67,19 +46,20 @@ public function getNameAccountKeySync(
PublicKey $nameParent = null
): PublicKey {
$seeds = [$hashed_name];
+ $programIdPublicKey = new PublicKey($this->config['NAME_PROGRAM_ID']);
if ($nameClass) {
$seeds[] = $nameClass->toBuffer();
} else {
- $seeds[] = str_repeat("\0", 32);
+ $seeds[] = Buffer::alloc(32);
}
if ($nameParent) {
$seeds[] = $nameParent->toBuffer();
} else {
- $seeds[] = str_repeat("\0", 32);
+ $seeds[] = Buffer::alloc(32);
}
[$nameAccountKey] = PublicKey::findProgramAddressSync(
$seeds,
- new PublicKey($this->config['NAME_PROGRAM_ID'])
+ $programIdPublicKey
);
return $nameAccountKey;
}
@@ -131,7 +111,7 @@ function getDomainKeySync(string $domain, ?string $record = null): array {
$prefix = $record ? $record : "\x00";
$sub = $prefix . $splitted[0];
$parentKey = $this->_deriveSync($splitted[1])['pubkey'];
- $result = $this->_deriveSync($sub, new PublicKey($parentKey), new PublicKey($recordClass));
+ $result = $this->_deriveSync($sub, $parentKey, $recordClass);
return array_merge($result, ['isSub' => true, 'parent' => $parentKey]);
} else if (count($splitted) === 3 && $record) {
// Parent key
@@ -154,7 +134,7 @@ function _deriveSync(string $name, PublicKey $parent = null, PublicKey $classKey
// Assuming these functions exist elsewhere in your codebase
$hashedDomainName = $this->getHashedNameSync($name);
$pubkey = $this->getNameAccountKeySync($hashedDomainName, $classKey, $parent ?: new PublicKey($this->config['ROOT_DOMAIN_ACCOUNT']));
- return ['pubkey' => $pubkey, 'hashed' => $hashed];
+ return ['pubkey' => $pubkey, 'hashed' => $hashedDomainName];
}
}
diff --git a/src/Programs/SnsProgram.php b/src/Programs/SnsProgram.php
new file mode 100644
index 0000000..be4df0c
--- /dev/null
+++ b/src/Programs/SnsProgram.php
@@ -0,0 +1,40 @@
+config = $config;
+ } else {
+ $this->config = $this->loadConstants();
+ }
+ $sns_records_id = new PublicKey($this->config['BONFIDA_SNS_RECORDS_ID']);
+
+ $this->centralStateSNSRecords = PublicKey::findProgramAddressSync(
+ [$sns_records_id],
+ $sns_records_id);
+
+ return $this;
+ }
+
+
+}
diff --git a/src/Programs/SplToken/Actions/SPLTokenActions.php b/src/Programs/SplToken/Actions/SPLTokenActions.php
index 467ca19..f945aec 100644
--- a/src/Programs/SplToken/Actions/SPLTokenActions.php
+++ b/src/Programs/SplToken/Actions/SPLTokenActions.php
@@ -8,13 +8,12 @@
use Attestto\SolanaPhpSdk\Exceptions\InputValidationException;
use Attestto\SolanaPhpSdk\Exceptions\InvalidIdResponseException;
use Attestto\SolanaPhpSdk\Exceptions\MethodNotFoundException;
-use Attestto\SolanaPhpSdk\Exceptions\TokenAccountNotFoundError;
use Attestto\SolanaPhpSdk\Exceptions\TokenInvalidAccountOwnerError;
use Attestto\SolanaPhpSdk\Exceptions\TokenInvalidMintError;
use Attestto\SolanaPhpSdk\Exceptions\TokenOwnerOffCurveError;
use Attestto\SolanaPhpSdk\Keypair;
+use Attestto\SolanaPhpSdk\Programs\SplToken\State\Account;
use Attestto\SolanaPhpSdk\PublicKey;
-use Attestto\SolanaPhpSdk\State\Account;
use Attestto\SolanaPhpSdk\Transaction;
use Attestto\SolanaPhpSdk\Util\Commitment;
use Attestto\SolanaPhpSdk\Util\ConfirmOptions;
diff --git a/src/Programs/SplToken/Instructions/SPLTokenInstructions.php b/src/Programs/SplToken/Instructions/SPLTokenInstructions.php
index 2fa88a8..911c390 100644
--- a/src/Programs/SplToken/Instructions/SPLTokenInstructions.php
+++ b/src/Programs/SplToken/Instructions/SPLTokenInstructions.php
@@ -3,13 +3,11 @@
namespace Attestto\SolanaPhpSdk\Programs\SplToken\Instructions;
use Attestto\SolanaPhpSdk\Exceptions\InputValidationException;
-use Attestto\SolanaPhpSdk\Programs\SplTokenProgram;
use Attestto\SolanaPhpSdk\Programs\SystemProgram;
use Attestto\SolanaPhpSdk\PublicKey;
use Attestto\SolanaPhpSdk\TransactionInstruction;
use Attestto\SolanaPhpSdk\Util\AccountMeta;
use Attestto\SolanaPhpSdk\Util\Buffer;
-use Attestto\SolanaPhpSdk\Programs\SplToken\Instructions\TokenInstruction;
trait SPLTokenInstructions
{
@@ -57,18 +55,18 @@ public function createAssociatedTokenAccountInstruction(
* @param PublicKey $owner
* @param PublicKey $mint
* @param Buffer $instructionData
- * @param string|null $programId
- * @param string|null $associatedTokenProgramId
+ * @param string|PublicKey|null $programId
+ * @param string|PublicKey|null $associatedTokenProgramId
* @return TransactionInstruction
*/
public function buildAssociatedTokenAccountInstruction(
- PublicKey $payer,
- PublicKey $associatedToken,
- PublicKey $owner,
- PublicKey $mint,
- Buffer $instructionData,
- $programId = new PublicKey(self::TOKEN_PROGRAM_ID),
- $associatedTokenProgramId = new PublicKey(self::ASSOCIATED_TOKEN_PROGRAM_ID)
+ PublicKey $payer,
+ PublicKey $associatedToken,
+ PublicKey $owner,
+ PublicKey $mint,
+ Buffer $instructionData,
+ string|PublicKey|null $programId = new PublicKey(self::TOKEN_PROGRAM_ID),
+ string|PublicKey|null $associatedTokenProgramId = new PublicKey(self::ASSOCIATED_TOKEN_PROGRAM_ID)
): TransactionInstruction
{
@@ -95,7 +93,6 @@ public function buildAssociatedTokenAccountInstruction(
*/
function createSyncNativeInstruction(PublicKey $owner, string $programId = self::TOKEN_PROGRAM_ID): TransactionInstruction
{
-
$keys = [
new AccountMeta($owner, false, true),
];
diff --git a/src/State/Account.php b/src/Programs/SplToken/State/Account.php
similarity index 97%
rename from src/State/Account.php
rename to src/Programs/SplToken/State/Account.php
index 653420c..41a8aee 100644
--- a/src/State/Account.php
+++ b/src/Programs/SplToken/State/Account.php
@@ -1,6 +1,6 @@
'application/json',
],
'body' => $body,
+
];
$response = $this->httpClient->request('POST', $this->endpoint, $options);
@@ -118,6 +119,7 @@ public function buildRpc(string $method, array $params): array
'id' => $this->randomKey,
'method' => $method,
'params' => $params,
+
];
}
diff --git a/src/Transaction.php b/src/Transaction.php
index cd7cbe2..4182ce7 100644
--- a/src/Transaction.php
+++ b/src/Transaction.php
@@ -87,7 +87,7 @@ public function add(...$items): Transaction
{
foreach ($items as $item) {
if ($item instanceof TransactionInstruction) {
- array_push($this->instructions, $item);
+ $this->instructions[] = $item;
} elseif ($item instanceof Transaction) {
array_push($this->instructions, ...$item->instructions);
} else {
diff --git a/src/Util/Buffer.php b/src/Util/Buffer.php
index 8c71062..a23b3e7 100644
--- a/src/Util/Buffer.php
+++ b/src/Util/Buffer.php
@@ -10,6 +10,7 @@
/**
* A convenient wrapper class around an array of bytes (int's).
+ *
*/
class Buffer implements Countable
{
@@ -45,6 +46,7 @@ class Buffer implements Countable
*/
protected ?string $datatype = null;
+
/**
* @param mixed $value
*/
@@ -81,11 +83,33 @@ public function __construct($value = null, ?string $datatype = null, ?bool $sign
}
}
+ /**
+ * @throws InputValidationException
+ */
+ public static function concat(array $buffers): static
+ {
+ $data = [];
+ foreach ($buffers as $buffer) {
+ $data = array_merge($data, $buffer->toArray());
+ }
+
+ return new static($data);
+ }
+
+ /**
+ * @throws InputValidationException
+ */
+ public static function fromArray(array $array): static
+ {
+ return new static($array);
+ }
+
/**
* For convenience.
*
* @param $value
* @return Buffer
+ * @throws InputValidationException
*/
public static function from($value = null, ?string $format = null, ?bool $signed = null): Buffer
{
@@ -97,6 +121,7 @@ public static function from($value = null, ?string $format = null, ?bool $signed
*
* @param string $value
* @return Buffer
+ * @throws InputValidationException
*/
public static function fromBase58(string $value): Buffer
{
@@ -239,7 +264,7 @@ public function value(?int $length = null)
* @return string
* @throws InputValidationException
*/
- protected function computedFormat()
+ protected function computedFormat(): string
{
if (! $this->datatype) {
throw new InputValidationException('Trying to calculate format of unspecified buffer. Please specify a datatype.');
@@ -256,4 +281,14 @@ protected function computedFormat()
}
}
+ /**
+ * @return Buffer
+ * @throws InputValidationException
+ */
+ public static function alloc(int $size): Buffer
+ {
+ return new static(array_fill(0, $size, 0));
+
+ }
+
}
diff --git a/temp/SNS/Constants/config.json b/temp/SNS/Constants/config.json
new file mode 100644
index 0000000..a1005a7
--- /dev/null
+++ b/temp/SNS/Constants/config.json
@@ -0,0 +1,92 @@
+{
+ "SYSTEM_PROGRAM_ID": "11111111111111111111111111111111",
+ "NAME_PROGRAM_ID": "namesLPneVptA9Z5rqUDD9tMTWEJwofgaYwp8cawRkX",
+ "HASH_PREFIX": "SPL Name Service",
+ "ROOT_DOMAIN_ACCOUNT": "58PwtjSDuFHuUkYjH9BYnnQKHfwo9reZhC2zMJv9JPkx",
+ "REGISTER_PROGRAM_ID": "jCebN34bUfdeUYJT13J1yG16XWQpt5PDx6Mse9GUqhR",
+ "PYTH_FIDA_PRICE_ACC": "ETp9eKXVv1dWwHSpsXRUuXHmw24PwRkttCGVgpZEY9zF",
+ "BONFIDA_FIDA_BNB": "AUoZ3YAhV3b2rZeEH93UMZHXUZcTramBvb4d9YEVySkc",
+ "REVERSE_LOOKUP_CLASS": "33m47vH6Eav6jr5Ry86XjhRft2jRBLDnDgPSHoquXi2Z",
+ "TWITTER_VERIFICATION_AUTHORITY": "FvPH7PrVrLGKPfqaf3xJodFTjZriqrAXXLTVWEorTFBi",
+ "TWITTER_ROOT_PARENT_REGISTRY_KEY": "4YcexoW3r78zz16J2aqmukBLRwGq6rAvWzJpkYAXqebv",
+ "SOL_RECORD_SIG_LEN": 96,
+ "BONFIDA_USDC_BNB": "DmSyHDSM9eSLyvoLsPvDr5fRRFZ7Bfr3h3ULvWpgQaq7",
+ "USDC_MINT": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
+ "REFERRERS": {
+ "test_wallet": "3ogYncmMM5CmytsGCqKHydmXmKUZ6sGWvizkzqwT7zb1",
+ "4everland": "DM1jJCkZZEwY5tmWbgvKRxsDFzXCdbfrYCCH1CtwguEs",
+ "bandit_network": "ADCp4QXFajHrhy4f43pD6GJFtQLkdBY2mjS9DfCk7tNW",
+ "altoscan": "2XTgjw8yi1E3Etgj4CUyRD7Zk49gynH2U9gA5N2MY4NP",
+ "solscan": "5PwNeqQPiygQks9R17jUAodZQNuhvCqqkrxSaeNE8qTR",
+ "domain_labs": "8kJqxAbqbPLGLMgB6FhLcnw2SiUEavx2aEGM3WQGhtJF",
+ "solflare": "HemvJzwxvVpWBjPETpaseAH395WAxb2G73MeUfjVkK1u",
+ "solnames": "7hMiiUtkH4StMPJxyAtvzXTUjecTniQ8czkCPusf5eSW",
+ "brave": "DGpjHo4yYA3NgHvhHTp3XfBFrESsx1DnhfTr8D881ZBM",
+ "585_eth": "7vWSqSw1eCXZXXUubuHWssXELNQ8MLaDgAs2ErEfCKxn",
+ "wdotsol": "5F6gcdzpw7wUjNEugdsD4aLJdEQ4Wt8d6E85vaQXZQSJ",
+ "godid": "XEy9o73JBN2pEuN7aspe8mVLaWbL4ozjJs1tNRxx8bL"
+ },
+ "TOKENS_SYM_MINT": {
+ "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v": "USDC",
+ "Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB": "USDT",
+ "So11111111111111111111111111111111111111112": "SOL",
+ "EchesyfXePKdLtoiZSL8pBe8Myagyy8ZRqsACNCFGnvp": "FIDA",
+ "mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So": "MSOL",
+ "DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263": "BONK",
+ "EPeUFDgHRxs9xxEPVaL6kfGQvCon7jmAWKVUHuux1Tpz": "BAT",
+ "HZ1JovNiVvGrGNiiYvEozEVgZ58xaU3RKwX8eACQBCt3": "PYTH",
+ "bSo13r4TkiE4KumL71LsHTPpL2euBYLFx6h9HP3piy1": "BSOL",
+ "6McPRfPV6bY1e9hLxWyG54W9i9Epq75QBvXg2oetBVTB": "INJ"
+ },
+ "PYTH_FEEDS": {
+ "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v": {
+ "price": "Gnt27xtC473ZT2Mw5u8wZ68Z3gULkSTb5DuxJy7eJotD",
+ "product": "8GWTTbNiXdmyZREXbjsZBmCRuzdPrW55dnZGDkTRjWvb"
+ },
+ "Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB": {
+ "price": "3vxLXJqLqF3JG5TCbYycbKWRBbCJQLxQmBGCkyqEEefL",
+ "product": "Av6XyAMJnyi68FdsKSPYgzfXGjYrrt6jcAMwtvzLCqaM"
+ },
+ "So11111111111111111111111111111111111111112": {
+ "price": "H6ARHf6YXhGYeQfUzQNGk6rDNnLBQKrenN712K4AQJEG",
+ "product": "ALP8SdU9oARYVLgLR7LrqMNCYBnhtnQz1cj6bwgwQmgj"
+ },
+ "EchesyfXePKdLtoiZSL8pBe8Myagyy8ZRqsACNCFGnvp": {
+ "price": "ETp9eKXVv1dWwHSpsXRUuXHmw24PwRkttCGVgpZEY9zF",
+ "product": "HyEB4Goiv7QyfFStaBn49JqQzSTV1ybtVikwsMLH1f2M"
+ },
+ "mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So": {
+ "price": "E4v1BBgoso9s64TQvmyownAVJbhbEPGyzA3qn4n46qj9",
+ "product": "BS2iAqT67j8hA9Jji4B8UpL3Nfw9kwPfU5s4qeaf1e7r"
+ },
+ "DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263": {
+ "price": "8ihFLu5FimgTQ1Unh4dVyEHUGodJ5gJQCrQf4KUVB9bN",
+ "product": "FerFD54J6RgmQVCR5oNgpzXmz8BW2eBNhhirb1d5oifo"
+ },
+ "EPeUFDgHRxs9xxEPVaL6kfGQvCon7jmAWKVUHuux1Tpz": {
+ "price": "AbMTYZ82Xfv9PtTQ5e1fJXemXjzqEEFHP3oDLRTae6yz",
+ "product": "8xTEctXKo6Xo3EzNhSNp4TUe8mgfwWFbDUXJhuubvrKx"
+ },
+ "HZ1JovNiVvGrGNiiYvEozEVgZ58xaU3RKwX8eACQBCt3": {
+ "price": "nrYkQQQur7z8rYTST3G9GqATviK5SxTDkrqd21MW6Ue",
+ "product": "AiQB4WngNPKDe3iWAwZmMzbULDAAfUD6Sr1knfZNJj3y"
+ },
+ "bSo13r4TkiE4KumL71LsHTPpL2euBYLFx6h9HP3piy1": {
+ "price": "AFrYBhb5wKQtxRS9UA9YRS4V3dwFm7SqmS6DHKq6YVgo",
+ "product": "3RtUHQR2LQ7su5R4zWwjupx72sWRGvLA4cFmnbHnT9M7"
+ },
+ "6McPRfPV6bY1e9hLxWyG54W9i9Epq75QBvXg2oetBVTB": {
+ "price": "9EdtbaivHQYA4Nh3XzGR6DwRaoorqXYnmpfsnFhvwuVj",
+ "product": "5Q5kyCVzssrGMd2BniSdVeRwjNWrGGrFhMrgGt4zURyA"
+ }
+ },
+ "PYTH_MAPPING_ACC": "AHtgzX45WTKfkPG53L6WYhGEXwQkN1BVknET3sVsLL8J",
+ "VAULT_OWNER_DEPRECATED": "GcWEQ9K78FV7LEHteFVciYApERk5YvQuFDQPk1yYJVXi",
+ "VAULT_OWNER": "5D2zKog251d6KPCyFyLMt3KroWwXXPWSgTPyhV22K2gR",
+ "CUSTOM_BG_TLD": "BPeXUQDqGbzxeK1LJby6ugvCBuo7kRSEUkjD726mUVsz",
+ "WOLVES_COLLECTION_METADATA": "72aLKvXeV4aansAQtxKymeXDevT5ed6sCuz9iN62ugPT",
+ "METAPLEX_ID": "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s",
+ "NAME_TOKENIZER_ID" : "nftD3vbNkNqfj2Sd3HZwbpw4BxxKWr4AjGb9X38JeZk",
+ "MINT_PREFIX": "tokenized_name",
+ "BONFIDA_SNS_RECORDS_ID": "HP3D4D1ZCmohQGFVms2SS4LCANgJyksBf5s1F77FuFjZ"
+}
\ No newline at end of file
diff --git a/temp/SNS/Constants/record.json b/temp/SNS/Constants/record.json
new file mode 100644
index 0000000..5d6d777
--- /dev/null
+++ b/temp/SNS/Constants/record.json
@@ -0,0 +1,42 @@
+{
+ "Record": {
+ "IPFS": "IPFS",
+ "ARWV": "ARWV",
+ "SOL": "SOL",
+ "ETH": "ETH",
+ "BTC": "BTC",
+ "LTC": "LTC",
+ "DOGE": "DOGE",
+ "Email": "email",
+ "Url": "url",
+ "Discord": "discord",
+ "Github": "github",
+ "Reddit": "reddit",
+ "Twitter": "twitter",
+ "Telegram": "telegram",
+ "Pic": "pic",
+ "SHDW": "SHDW",
+ "POINT": "POINT",
+ "BSC": "BSC",
+ "Injective": "INJ",
+ "Backpack": "backpack",
+ "A": "A",
+ "AAAA": "AAAA",
+ "CNAME": "CNAME",
+ "TXT": "TXT",
+ "Background": "background"
+ },
+ "RECORD_V1_SIZE": {
+ "SOL": 96,
+ "ETH": 20,
+ "BSC": 20,
+ "Injective": 20,
+ "A": 4,
+ "AAAA": 16,
+ "Background": 32
+ },
+ "RecordVersion": {
+ "V1": 1,
+ "V2": 2
+ }
+}
diff --git a/config/SNS/InstructionBurn.php b/temp/SNS/InstructionBurn.php
similarity index 98%
rename from config/SNS/InstructionBurn.php
rename to temp/SNS/InstructionBurn.php
index 592bdd6..18e3a32 100644
--- a/config/SNS/InstructionBurn.php
+++ b/temp/SNS/InstructionBurn.php
@@ -1,6 +1,6 @@
0pQvfE-v3<2q&uvUq{4$=1mV&2oCM
zY_%9eydLdj$?Iyeb@p~x4j-0xHlJc>*4tr)3C(IiK?+ELi2^S@AN~A)r$3tiCoM{)
zfE0K#1#H-UY&U$VJX`;~p4Y#!>gz@)<8p>yKLJeqD1N1faliP2tjX5N3Qa!(A%lVx
H_*Vt)uJaO^
literal 0
HcmV?d00001
diff --git a/tests/Unit/.DS_Store b/tests/Unit/.DS_Store
index 2dc1b518f3243146cd67162358550fb5012cd953..a2a5d62eef95f0a2a4ed6fdd3b8228a7f3b0351b 100644
GIT binary patch
delta 98
zcmZoMXfc=|&e%S&P;8=}q9_vs0|O%ig8&0V5kn$FE< assertEquals($rawCreateAccountBinary, $bufferable->toArray());
}
-}
\ No newline at end of file
+
+ /**
+ * @throws InputValidationException
+ */
+ #[Test]
+ public function test_concat()
+ {
+ $buffer1 = Buffer::from(1, Buffer::TYPE_INT, false);
+ $buffer2 = Buffer::from(2, Buffer::TYPE_INT, false);
+ $buffer3 = Buffer::from(3, Buffer::TYPE_INT, false);
+
+ $buffer = Buffer::concat([$buffer1, $buffer2, $buffer3]);
+
+ $this->assertEquals([1, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, 0], $buffer->toArray());
+ }
+
+ /**
+ * @throws InputValidationException
+ */
+ #[Test]
+ public function test_fromArray()
+ {
+ $buffer = Buffer::fromArray([1, 2, 3, 4]);
+ $this->assertEquals([1, 2, 3, 4], $buffer->toArray());
+ }
+}
diff --git a/tests/Unit/Programs/.DS_Store b/tests/Unit/Programs/.DS_Store
new file mode 100644
index 0000000000000000000000000000000000000000..5aa9872c84d5e60422502a2b061ace1922a8e9dd
GIT binary patch
literal 6148
zcmeHKO>fgc5S?uTai~BMY6TpSEOCuWC3``7-t2CHGzEc>5Q=uB*|#4vv);G%te1$yU>w~c>JX6wWo%wTagOjf>w>J9
zo)%E37?M)jrGg~ATd=krmI2Ga|Hc4+yX!Qhgd+0s-G2Xm3kv9f_9&*3D%zl&_9=gy
z%C})ELwIq@cmUn_q69UfYxD&66+CwlDW;F#vcc~}`*bE+15fmn{P{V>&GW6oNtv4`
z`yA$JQdYg*u~=y|FI;RnEoaqv?eEKpUj@~;90bKnZtY2#hNtx)e4fOUQD^O;%&H*C
z;zBtjQ4Et;FOn>hlYty(QK@`=J>ayR_Na4XI^FDVZFSxLc7N7&r`wyou6yt9{n@PT
ztlzr5^KA4!J;>xCbA()pWU1t`!BaRw#Vq=RUu3DwIE}LP6|*@3Wgz#Ln<99YA2;PH
zeDgosSaEVD2AWoujREr-I;+dJFuNYhfMwvX8Q}cjLK!`SwMLaXP^c>au!(LZsPm5j
z`?v-@gSAGCK!kP$YFA;d7(%s%4By+YdERN4w7y1Uu!gjSr<$}T-$Ew0d
d@pY&YjJaF^dIoEa=z-WD0Y!r?ECc_Pfv?kAm=pj2
literal 0
HcmV?d00001
diff --git a/tests/Unit/Programs/MetaPlexProgramTest.php b/tests/Unit/Programs/MetaPlexProgramTest.php
new file mode 100644
index 0000000..701c86a
--- /dev/null
+++ b/tests/Unit/Programs/MetaPlexProgramTest.php
@@ -0,0 +1,38 @@
+assembleClient('POST', []);
+
+ $solana = new SystemProgram($client);
+
+ $this->expectException(AccountNotFoundException::class);
+ $solana->getAccountInfo('abc123');
+ }
+
+
+
+}
diff --git a/tests/Unit/Programs/Sns/DerivationTest.php b/tests/Unit/Programs/Sns/DerivationTest.php
new file mode 100644
index 0000000..50eb382
--- /dev/null
+++ b/tests/Unit/Programs/Sns/DerivationTest.php
@@ -0,0 +1,74 @@
+ 'bonfida',
+ 'address' => 'Crf8hzfthWGbGbLTVCiqRqV5MVnbpHB1L9KQMd6gsinb',
+ ],
+ [
+ 'domain' => 'bonfida.sol',
+ 'address' => 'Crf8hzfthWGbGbLTVCiqRqV5MVnbpHB1L9KQMd6gsinb',
+ ],
+ [
+ 'domain' => 'dex.bonfida',
+ 'address' => 'HoFfFXqFHAC8RP3duuQNzag1ieUwJRBv1HtRNiWFq4Qu',
+ ],
+ [
+ 'domain' => 'dex.bonfida.sol',
+ 'address' => 'HoFfFXqFHAC8RP3duuQNzag1ieUwJRBv1HtRNiWFq4Qu',
+ ],
+ ];
+
+ public function setUp(): void
+ {
+ parent::setUp();
+ }
+
+ #[Test]
+ public function test_getHashedNameSync(){
+ $client = $this->createMock(SolanaRpcClient::class);
+ $sns = new SnsProgram($client);
+ $hashedName = $sns->getHashedNameSync('bonfida');
+ $bs58HashedName = $hashedName->toBase58String();
+ $this->assertEquals('AcmVjPtaDyNboWGSKjYHxea1QDgN648T4Je3HUpkHecf', $bs58HashedName);
+ }
+
+ /**
+ * @throws InputValidationException
+ */
+ #[Test]
+ public function test_deriveSynch(){
+ $client = $this->createMock(SolanaRpcClient::class);
+ $sns = new SnsProgram($client);
+ $hashedName = $sns->_deriveSync('bonfida');
+ $nameAccountKey = $sns->getNameAccountKeySync($hashedName['hashed']);
+ $nameAccountKeyBs58 = $nameAccountKey->toBase58();
+ $this->assertEquals('85v6oF1VnGNeT4oV2fH8HpVBj3k3U4m6uNnWYT8AcA5H',$nameAccountKeyBs58 );
+ }
+
+ #[Test]
+ public function test_getDomainKeySync()
+ {
+ $client = $this->createMock(SolanaRpcClient::class);
+ $sns = new SnsProgram($client);
+ foreach ($this->items as $item) {
+ $result = $sns->getDomainKeySync($item['domain']);
+ $this->assertInstanceOf(PublicKey::class, $result['pubkey']);
+ $this->assertEquals($item['address'], $result['pubkey']->toBase58());
+ }
+ }
+
+}
diff --git a/tests/Unit/Programs/Sns/InstructionsTest.php b/tests/Unit/Programs/Sns/InstructionsTest.php
new file mode 100644
index 0000000..f25f04a
--- /dev/null
+++ b/tests/Unit/Programs/Sns/InstructionsTest.php
@@ -0,0 +1,163 @@
+createMock(SolanaRpcClient::class);
+
+ $sns = new SnsProgram($client);
+ $instruction = $sns->createInstruction(
+ $nameProgramId,
+ $systemProgramId,
+ $nameKey,
+ $nameOwnerKey,
+ $payerKey,
+ $hashed_name,
+ $lamports,
+ $space,
+ $nameClassKey,
+ $nameParent,
+ $nameParentOwner
+ );
+
+ // Assert
+ $this->assertInstanceOf(TransactionInstruction::class, $instruction);
+ $this->assertEquals(0, $instruction->data->toArray()[0]);
+
+ // TODO: Add more assertions here to verify the properties of the returned TransactionInstruction
+ }
+
+ #[Test]
+ public function test_updateInstruction()
+ {
+ // Arrange
+ $nameProgramId = new PublicKey(Buffer::alloc(32));
+ $nameAccountKey = new PublicKey(Buffer::alloc(32));
+ $offset = new Buffer(96, Buffer::TYPE_INT, false);
+ $inputData = new Buffer('INPUT DATA', );
+ $nameUpdateSigner = new PublicKey(Buffer::alloc(32));
+
+ $client = $this->createMock(SolanaRpcClient::class);
+
+ $sns = new SnsProgram($client);
+ $instruction = $sns->updateInstruction(
+ $nameProgramId,
+ $nameAccountKey,
+ $offset,
+ $inputData,
+ $nameUpdateSigner
+ );
+
+ // Assert
+ $this->assertInstanceOf(TransactionInstruction::class, $instruction);
+ $this->assertEquals(1, $instruction->data->toArray()[0]);
+ }
+
+ #[Test]
+ public function test_transferInstruction()
+ {
+ // Arrange
+ $nameProgramId = new PublicKey(Buffer::alloc(32));
+ $nameAccountKey = new PublicKey(Buffer::alloc(32));
+ $newOwnerKey = new PublicKey(Buffer::alloc(32));
+ $currentNameOwnerKey = new PublicKey(Buffer::alloc(32));
+
+
+ $client = $this->createMock(SolanaRpcClient::class);
+
+ $sns = new SnsProgram($client);
+ $instruction = $sns->transferInstruction(
+ $nameProgramId,
+ $nameAccountKey,
+ $newOwnerKey,
+ $currentNameOwnerKey,
+ null, null, null
+ );
+
+ // Assert
+ $this->assertInstanceOf(TransactionInstruction::class, $instruction);
+ $this->assertEquals(2, $instruction->data->toArray()[0]);
+ }
+
+ #[Test]
+ public function test_reallocInstruction()
+ {
+ // Arrange
+ $nameProgramId = new PublicKey(Buffer::alloc(32));
+ $systemProgramId = new PublicKey(Buffer::alloc(32));
+ $nameAccountKey = new PublicKey(Buffer::alloc(32));
+ $currentNameOwnerKey = new PublicKey(Buffer::alloc(32));
+ $space = new Buffer(2000, Buffer::TYPE_INT, false);
+
+ $client = $this->createMock(SolanaRpcClient::class);
+
+ $sns = new SnsProgram($client);
+ $instruction = $sns->reallocInstruction(
+ $nameProgramId,
+ $systemProgramId,
+ $currentNameOwnerKey, // Payer
+ $nameAccountKey,
+ $currentNameOwnerKey,
+ $space
+ );
+
+ // Assert
+ $this->assertInstanceOf(TransactionInstruction::class, $instruction);
+ $this->assertEquals(4, $instruction->data->toArray()[0]);
+ }
+
+ #[Test]
+ public function test_deleteInstruction()
+ {
+ // Arrange
+ $nameProgramId = new PublicKey(Buffer::alloc(32));
+
+ $nameAccountKey = new PublicKey(Buffer::alloc(32));
+ $currentNameOwnerKey = new PublicKey(Buffer::alloc(32));
+
+
+ $client = $this->createMock(SolanaRpcClient::class);
+
+ $sns = new SnsProgram($client);
+ $instruction = $sns->deleteInstruction(
+ $nameProgramId,
+ $nameAccountKey,
+ $currentNameOwnerKey, // Refund Target
+ $currentNameOwnerKey
+ );
+
+ // Assert
+ $this->assertInstanceOf(TransactionInstruction::class, $instruction);
+ $this->assertEquals(3, $instruction->data->toArray()[0]);
+ }
+
+}
diff --git a/tests/Unit/Programs/Sns/NameRegistryStateTest.php b/tests/Unit/Programs/Sns/NameRegistryStateTest.php
new file mode 100644
index 0000000..ea0d260
--- /dev/null
+++ b/tests/Unit/Programs/Sns/NameRegistryStateTest.php
@@ -0,0 +1,68 @@
+ 'bonfida',
+ 'address' => 'Crf8hzfthWGbGbLTVCiqRqV5MVnbpHB1L9KQMd6gsinb',
+ ],
+ [
+ 'domain' => 'bonfida.sol',
+ 'address' => 'Crf8hzfthWGbGbLTVCiqRqV5MVnbpHB1L9KQMd6gsinb',
+ ],
+ [
+ 'domain' => 'dex.bonfida',
+ 'address' => 'HoFfFXqFHAC8RP3duuQNzag1ieUwJRBv1HtRNiWFq4Qu',
+ ],
+ [
+ 'domain' => 'dex.bonfida.sol',
+ 'address' => 'HoFfFXqFHAC8RP3duuQNzag1ieUwJRBv1HtRNiWFq4Qu',
+ ],
+ ];
+
+ public function setUp(): void
+ {
+ parent::setUp();
+ }
+
+ #[Test]
+ public function test_deserialize(){
+ $accountData = 'PVPCSzg2DtOBOiPfst/YIKtYIct5KaONLqqyUug4JZXybLcicCAgnC2mdJSPjzwzDuT5o4Yla9FPN6bgxWdUKwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAY2x1ZTIuc29sAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==';
+ $dataBuffer = Buffer::from(base64_decode($accountData));
+ // $accountData = $dataBuffer->slice(96);
+ $nameRegistryState = NameRegistryStateAccount::deserialize($dataBuffer->toArray());
+ $this->assertEquals('58PwtjSDuFHuUkYjH9BYnnQKHfwo9reZhC2zMJv9JPkx', $nameRegistryState->parentName->toBase58());
+ $this->assertEquals('HKKp49qGWXd639QsuH7JiLijfVW5UtCVY4s1n2HANwEA', $nameRegistryState->owner->toBase58());
+ $this->assertEquals('11111111111111111111111111111111', $nameRegistryState->class->toBase58());
+ }
+
+ #[Test]
+ public function test_retrieve(){
+
+ $rpcClient = new SolanaRpcClient('https://api.mainnet-beta.solana.com');
+ $connection = new Connection($rpcClient);
+ $nameRegistryState = NameRegistryStateAccount::retrieve($connection, 'Crf8hzfthWGbGbLTVCiqRqV5MVnbpHB1L9KQMd6gsinb');
+ $this->assertEquals('HKKp49qGWXd639QsuH7JiLijfVW5UtCVY4s1n2HANwEA', $nameRegistryState['registry']->owner->toBase58());
+ $this->assertEquals('58PwtjSDuFHuUkYjH9BYnnQKHfwo9reZhC2zMJv9JPkx', $nameRegistryState['registry']->parentName->toBase58());
+ $this->assertEquals('11111111111111111111111111111111', $nameRegistryState['registry']->class->toBase58());
+ }
+
+
+
+
+
+}
diff --git a/tests/Unit/Programs/SplProgramTest.php b/tests/Unit/Programs/SplProgramTest.php
index 290ccf7..e8ee718 100644
--- a/tests/Unit/Programs/SplProgramTest.php
+++ b/tests/Unit/Programs/SplProgramTest.php
@@ -7,13 +7,13 @@
use Attestto\SolanaPhpSdk\Exceptions\GenericException;
use Attestto\SolanaPhpSdk\Exceptions\InputValidationException;
use Attestto\SolanaPhpSdk\Keypair;
+use Attestto\SolanaPhpSdk\Programs\SplToken\State\Account;
use Attestto\SolanaPhpSdk\Programs\SplTokenProgram;
use Attestto\SolanaPhpSdk\Programs\SystemProgram;
+use Attestto\SolanaPhpSdk\PublicKey;
use Attestto\SolanaPhpSdk\SolanaRpcClient;
use Attestto\SolanaPhpSdk\Tests\TestCase;
use PHPUnit\Framework\Attributes\Test;
-use Attestto\SolanaPhpSdk\PublicKey;
-use Attestto\SolanaPhpSdk\State\Account;
class SplProgramTest extends TestCase
From d95c43c8c719211c1d5da0afb740621c4a12fc18 Mon Sep 17 00:00:00 2001
From: Eduardo Chongkan
Date: Wed, 8 May 2024 22:28:27 -0600
Subject: [PATCH 2/4] add connection->getMinimumBalanceForRentExcemption()
---
src/Connection.php | 4 ++++
tests/Feature/ConnectionFeatureTest.php | 9 +++++++++
2 files changed, 13 insertions(+)
diff --git a/src/Connection.php b/src/Connection.php
index e36daf6..39bbc52 100644
--- a/src/Connection.php
+++ b/src/Connection.php
@@ -172,4 +172,8 @@ public function getProgramAccounts(string $programIdBs58, $dataSlice, $filters)
}
+ public function getMinimumBalanceForRentExemption(array $params = [1024]){
+ return $this->client->call('getMinimumBalanceForRentExemption', $params );
+ }
+
}
diff --git a/tests/Feature/ConnectionFeatureTest.php b/tests/Feature/ConnectionFeatureTest.php
index efff2b6..07db390 100644
--- a/tests/Feature/ConnectionFeatureTest.php
+++ b/tests/Feature/ConnectionFeatureTest.php
@@ -185,6 +185,15 @@ public function testGetBalance()
$this->assertIsFloat($result);
}
+ #[Test]
+ public function test_getMinimumBalanceForRentExemption(){
+ $client = new SolanaRpcClient($this->endpoint);
+ $connection = new Connection($client);
+ $result = $connection->getMinimumBalanceForRentExemption([2000]);
+ $this->assertIsInt($result);
+
+ }
+
}
From 158897718a64e874377f79c80971b25bf039c2d6 Mon Sep 17 00:00:00 2001
From: Eduardo Chongkan
Date: Wed, 8 May 2024 23:36:56 -0600
Subject: [PATCH 3/4] Add test_getReverseKeySync
---
src/Connection.php | 4 +-
src/Programs/SNS/Bindings.php | 126 ++++++++++++++++++++-
src/Programs/SNS/Utils.php | 23 ++++
src/Programs/SnsProgram.php | 2 +
tests/Feature/ConnectionFeatureTest.php | 3 +-
tests/Unit/Programs/Sns/BindingsTest.php | 77 +++++++++++++
tests/Unit/Programs/Sns/DerivationTest.php | 22 ++++
7 files changed, 251 insertions(+), 6 deletions(-)
create mode 100644 tests/Unit/Programs/Sns/BindingsTest.php
diff --git a/src/Connection.php b/src/Connection.php
index 39bbc52..821b35c 100644
--- a/src/Connection.php
+++ b/src/Connection.php
@@ -172,8 +172,8 @@ public function getProgramAccounts(string $programIdBs58, $dataSlice, $filters)
}
- public function getMinimumBalanceForRentExemption(array $params = [1024]){
- return $this->client->call('getMinimumBalanceForRentExemption', $params );
+ public function getMinimumBalanceForRentExemption(int $space = 1024){
+ return $this->client->call('getMinimumBalanceForRentExemption', [$space] );
}
}
diff --git a/src/Programs/SNS/Bindings.php b/src/Programs/SNS/Bindings.php
index 05a9295..c0f920f 100644
--- a/src/Programs/SNS/Bindings.php
+++ b/src/Programs/SNS/Bindings.php
@@ -7,15 +7,29 @@
use Attestto\SolanaPhpSdk\Exceptions\AccountNotFoundException;
use Attestto\SolanaPhpSdk\Exceptions\SNSError;
use Attestto\SolanaPhpSdk\Programs\SNS\State\NameRegistryStateAccount;
+use Attestto\SolanaPhpSdk\Programs\SystemProgram;
use Attestto\SolanaPhpSdk\PublicKey;
+use Attestto\SolanaPhpSdk\TransactionInstruction;
+use Attestto\SolanaPhpSdk\Util\Buffer;
+use Exception;
-
+/**
+ * @method createInstruction($NAME_PROGRAM_ID, $programId, PublicKey $nameAccountKey, PublicKey $nameOwner, PublicKey $payerKey, Buffer $hashed_name, Buffer $param, Buffer $param1, PublicKey|null $nameClass, PublicKey|null $parentName, $nameParentOwner)
+ * @method getReverseKeySync(string $subdomain, true $true)
+ * @method createReverseName(mixed $pubkey, string $string, PublicKey $param, mixed $parent, PublicKey $owner)
+ * @method getNameOwner(Connection $connection, PublicKey $parentName)
+ * @method retrieve(Connection $connection, mixed $parent)
+ * @method transferInstruction(mixed $NAME_PROGRAM_ID, mixed $pubkey, PublicKey $newOwner, PublicKey|null $owner, $null, mixed $nameParent, $nameParentOwner)
+ */
trait Bindings
{
- use Utils;
+// use Utils;
+// use Instructions;
+
/**
* @throws SNSError
* @throws AccountNotFoundException
+ * @throws Exception
*/
public function createSubdomain(
Connection $connection,
@@ -66,4 +80,112 @@ public function createSubdomain(
return [[], $ixs];
}
+
+ /**
+ * Creates a name account with the given rent budget, allocated space, owner and class.
+ *
+ * @param Connection $connection The solana connection object to the RPC node
+ * @param string $name The name of the new account
+ * @param int $space The space in bytes allocated to the account
+ * @param PublicKey $payerKey The allocation cost payer
+ * @param PublicKey $nameOwner The pubkey to be set as owner of the new name account
+ * @param int|null $lamports The budget to be set for the name account. If not specified, it'll be the minimum for rent exemption
+ * @param PublicKey|null $nameClass The class of this new name
+ * @param PublicKey|null $parentName The parent name of the new name. If specified its owner needs to sign
+ * @return TransactionInstruction
+ * @throws Exception
+ */
+ public function createNameRegistry(
+ Connection $connection,
+ string $name,
+ int $space,
+ PublicKey $payerKey,
+ PublicKey $nameOwner,
+ int $lamports = null,
+ PublicKey $nameClass = null,
+ PublicKey $parentName = null
+ ): TransactionInstruction
+ {
+ $hashed_name = $this->getHashedNameSync($name);
+ $nameAccountKey = $this->getNameAccountKeySync($hashed_name, $nameClass, $parentName);
+
+ $balance = $lamports ?: $connection->getMinimumBalanceForRentExemption($space);
+
+ $nameParentOwner = null;
+ if ($parentName) {
+ $parentAccount = $this->getNameOwner($connection, $parentName);
+ $nameParentOwner = $parentAccount['registry']->owner;
+ }
+
+ return $this->createInstruction(
+ new PublicKey($this->config['NAME_PROGRAM_ID']),
+ SystemProgram::programId(),
+ $nameAccountKey,
+ $nameOwner,
+ $payerKey,
+ $hashed_name,
+ new Buffer($balance, Buffer::TYPE_LONG, false),
+ new Buffer($space, Buffer::TYPE_INT, false),
+ $nameClass,
+ $parentName,
+ $nameParentOwner
+ );
+ }
+
+
+
+ /**
+ * This function is used to transfer the ownership of a subdomain in the Solana Name Service.
+ *
+ * @param Connection $connection The Solana RPC connection object.
+ * @param string $subdomain The subdomain to transfer. It can be with or without .sol suffix (e.g., 'something.bonfida.sol' or 'something.bonfida').
+ * @param PublicKey $newOwner The public key of the new owner of the subdomain.
+ * @param bool $isParentOwnerSigner A flag indicating whether the parent name owner is signing this transfer.
+ * @param PublicKey|null $owner The public key of the current owner of the subdomain. This is an optional parameter. If not provided, the owner will be resolved automatically. This can be helpful to build transactions when the subdomain does not exist yet.
+ *
+ * @return TransactionInstruction
+ * @throws Exception
+ */
+ public function transferSubdomain(
+ Connection $connection,
+ string $subdomain,
+ PublicKey $newOwner,
+ bool $isParentOwnerSigner = false,
+ PublicKey $owner = null
+ ): TransactionInstruction
+ {
+ $domainKeySync = $this->getDomainKeySync($subdomain);
+ $pubkey = $domainKeySync['pubkey'];
+ $isSub = $domainKeySync['isSub'];
+ $parent = $domainKeySync['parent'];
+
+ if (!$parent || !$isSub) {
+ throw new SNSError(SNSError::InvalidSubdomain);
+ }
+
+ if (!$owner) {
+ $registry = $this->retrieve($connection, $pubkey);
+ $owner = $registry['registry']->owner;
+ }
+
+ $nameParent = null;
+ $nameParentOwner = null;
+
+ if ($isParentOwnerSigner) {
+ $nameParent = $parent;
+ $parentAccount = $this->retrieve($connection, $parent);
+ $nameParentOwner = $parentAccount['registry']->owner;
+ }
+
+ return $this->transferInstruction(
+ $this->config['NAME_PROGRAM_ID'],
+ $pubkey,
+ $newOwner,
+ $owner,
+ null,
+ $nameParent,
+ $nameParentOwner
+ );
+ }
+
}
diff --git a/src/Programs/SNS/Utils.php b/src/Programs/SNS/Utils.php
index e6344ba..aff2b3d 100644
--- a/src/Programs/SNS/Utils.php
+++ b/src/Programs/SNS/Utils.php
@@ -137,4 +137,27 @@ function _deriveSync(string $name, PublicKey $parent = null, PublicKey $classKey
return ['pubkey' => $pubkey, 'hashed' => $hashedDomainName];
}
+
+ /**
+ * This function can be used to get the key of the reverse account
+ *
+ * @param string $domain The domain to compute the reverse for
+ * @param bool|null $isSub Whether the domain is a subdomain or not
+ * @return PublicKey The public key of the reverse account
+ * @throws Exception
+ * @throws SNSError
+ * @throws InputValidationException
+ */
+ public function getReverseKeySync(string $domain, bool $isSub = null): PublicKey {
+ $domainKeySync = $this->getDomainKeySync($domain);
+ $pubkey = $domainKeySync['pubkey'];
+ $parent = $domainKeySync['parent'];
+ $hashedReverseLookup = $this->getHashedNameSync($pubkey->toBase58());
+ return $this->getNameAccountKeySync(
+ $hashedReverseLookup,
+ new PublicKey($this->config['REVERSE_LOOKUP_CLASS']),
+ $isSub ? $parent : null
+ );
+ }
+
}
diff --git a/src/Programs/SnsProgram.php b/src/Programs/SnsProgram.php
index be4df0c..5002851 100644
--- a/src/Programs/SnsProgram.php
+++ b/src/Programs/SnsProgram.php
@@ -4,6 +4,7 @@
use Attestto\SolanaPhpSdk\Exceptions\BaseSolanaPhpSdkException;
use Attestto\SolanaPhpSdk\Program;
+use Attestto\SolanaPhpSdk\Programs\SNS\Bindings;
use Attestto\SolanaPhpSdk\Programs\SNS\Utils;
use Attestto\SolanaPhpSdk\Programs\SNS\Instructions\Instructions;
use Attestto\SolanaPhpSdk\PublicKey;
@@ -15,6 +16,7 @@ class SnsProgram extends Program
use Instructions;
use Utils;
+ use Bindings;
public mixed $config;
diff --git a/tests/Feature/ConnectionFeatureTest.php b/tests/Feature/ConnectionFeatureTest.php
index 07db390..48e23d1 100644
--- a/tests/Feature/ConnectionFeatureTest.php
+++ b/tests/Feature/ConnectionFeatureTest.php
@@ -189,9 +189,8 @@ public function testGetBalance()
public function test_getMinimumBalanceForRentExemption(){
$client = new SolanaRpcClient($this->endpoint);
$connection = new Connection($client);
- $result = $connection->getMinimumBalanceForRentExemption([2000]);
+ $result = $connection->getMinimumBalanceForRentExemption(2000);
$this->assertIsInt($result);
-
}
diff --git a/tests/Unit/Programs/Sns/BindingsTest.php b/tests/Unit/Programs/Sns/BindingsTest.php
new file mode 100644
index 0000000..31a2489
--- /dev/null
+++ b/tests/Unit/Programs/Sns/BindingsTest.php
@@ -0,0 +1,77 @@
+createMock(SolanaRpcClient::class);
+ $connection = $this->createMock(Connection::class);
+ $sns = new SnsProgram($client);
+ try {
+ $instruction = $sns->createSubdomain(
+ $connection,
+ 'subdomain',
+ $nameOwnerKey,
+ 2000,
+ $nameOwnerKey
+ );
+ } catch (AccountNotFoundException|SNSError $e) {
+ $this->fail($e->getMessage());
+ }
+
+ // Assert
+ $this->assertInstanceOf(TransactionInstruction::class, $instruction);
+ $this->assertEquals(0, $instruction->data->toArray()[0]);
+
+ }
+
+ #[Test]
+ public function test_createNameRegistry()
+ {
+ // Arrange
+ $nameOwnerSigner = new PublicKey(Buffer::alloc(32));
+
+ $client = $this->createMock(SolanaRpcClient::class);
+ $connection = $this->createMock(Connection::class);
+ $sns = new SnsProgram($client);
+
+
+ $instruction = $sns->createNameRegistry(
+ $connection,
+ 'domain',
+ 2000,
+ $nameOwnerSigner,
+ $nameOwnerSigner, // could be someone else
+ null, null, null
+ );
+
+ // Assert
+ $this->assertInstanceOf(TransactionInstruction::class, $instruction);
+ $this->assertEquals(0, $instruction->data->toArray()[0]);
+ }
+
+
+}
diff --git a/tests/Unit/Programs/Sns/DerivationTest.php b/tests/Unit/Programs/Sns/DerivationTest.php
index 50eb382..9317aad 100644
--- a/tests/Unit/Programs/Sns/DerivationTest.php
+++ b/tests/Unit/Programs/Sns/DerivationTest.php
@@ -5,10 +5,12 @@
use Attestto\SolanaPhpSdk\Exceptions\InputValidationException;
+use Attestto\SolanaPhpSdk\Exceptions\SNSError;
use Attestto\SolanaPhpSdk\Programs\SnsProgram;
use Attestto\SolanaPhpSdk\PublicKey;
use Attestto\SolanaPhpSdk\Tests\TestCase;
use Attestto\SolanaPhpSdk\SolanaRpcClient;
+use PHPUnit\Framework\MockObject\Exception;
class DerivationTest extends TestCase
{
@@ -71,4 +73,24 @@ public function test_getDomainKeySync()
}
}
+ /**
+ * @throws SNSError
+ * @throws Exception
+ * @throws InputValidationException
+ */
+ #[Test]
+ public function test_getReverseKeySync()
+ {
+ $client = $this->createMock(SolanaRpcClient::class);
+ $sns = new SnsProgram($client);
+ foreach ($this->items as $item) {
+ $result = $sns->getReverseKeySync($item['domain']);
+ $this->assertInstanceOf(PublicKey::class, $result);
+ $this->assertTrue(
+ $result->toBase58() === 'DqgmWxe2PPrfy45Ja3UPyFGwcbRzkRuwXt3NyxjX8krg' ||
+ $result->toBase58() === 'BrRErziYEA9oBoDyYrdVF9p6Gs1QtdpaZ6AQpaybeZgf'
+ );
+ }
+ }
+
}
From 6f1208317567f14a131eb75b8b2d93031da49940 Mon Sep 17 00:00:00 2001
From: Eduardo Chongkan
Date: Thu, 9 May 2024 03:23:02 -0600
Subject: [PATCH 4/4] Test Bindings + Utils -- createSubdomain
---
build/html-coverage/Account.php.html | 10 +-
build/html-coverage/Accounts/Creator.php.html | 2 +-
.../Accounts/Did/ServiceStruct.php.html | 2 +-
.../Did/VerificationMethodStruct.php.html | 2 +-
.../html-coverage/Accounts/Did/dashboard.html | 2 +-
build/html-coverage/Accounts/Did/index.html | 2 +-
build/html-coverage/Accounts/DidData.php.html | 2 +-
.../html-coverage/Accounts/Metadata.php.html | 2 +-
.../Accounts/MetadataData.php.html | 2 +-
.../Accounts/Sns/NtfRecordAccount.php.html | 2 +-
.../html-coverage/Accounts/Sns/dashboard.html | 2 +-
build/html-coverage/Accounts/Sns/index.html | 2 +-
build/html-coverage/Accounts/dashboard.html | 2 +-
build/html-coverage/Accounts/index.html | 2 +-
.../html-coverage/Borsh/BinaryReader.php.html | 32 +-
.../html-coverage/Borsh/BinaryWriter.php.html | 26 +-
build/html-coverage/Borsh/Borsh.php.html | 54 +--
.../Borsh/BorshDeserializable.php.html | 24 +-
.../Borsh/BorshException.php.html | 2 +-
.../html-coverage/Borsh/BorshObject.php.html | 2 +-
.../Borsh/BorshSerializable.php.html | 16 +-
build/html-coverage/Borsh/dashboard.html | 2 +-
build/html-coverage/Borsh/index.html | 2 +-
build/html-coverage/Connection.php.html | 70 ++-
.../AccountNotFoundException.php.html | 2 +-
.../BaseSolanaPhpSdkException.php.html | 2 +-
.../Exceptions/GenericException.php.html | 2 +-
.../InputValidationException.php.html | 2 +-
.../InvalidIdResponseException.php.html | 2 +-
.../MethodNotFoundException.php.html | 2 +-
.../Exceptions/SNSError.php.html | 2 +-
.../Exceptions/TodoException.php.html | 2 +-
.../TokenAccountNotFoundError.php.html | 2 +-
.../TokenInvalidAccountOwnerError.php.html | 2 +-
.../Exceptions/TokenInvalidMintError.php.html | 2 +-
.../TokenOwnerOffCurveError.php.html | 2 +-
build/html-coverage/Exceptions/dashboard.html | 2 +-
build/html-coverage/Exceptions/index.html | 2 +-
build/html-coverage/Keypair.php.html | 36 +-
build/html-coverage/Message.php.html | 74 +--
build/html-coverage/Program.php.html | 6 +-
.../Programs/DidSolProgram.php.html | 2 +-
.../Programs/MetaplexProgram.php.html | 2 +-
.../html-coverage/Programs/SNS/Utils.php.html | 425 +++++++++++-------
.../html-coverage/Programs/SNS/dashboard.html | 41 +-
build/html-coverage/Programs/SNS/index.html | 100 ++---
.../SplToken/Actions/SPLTokenActions.php.html | 36 +-
.../Programs/SplToken/Actions/dashboard.html | 6 +-
.../Programs/SplToken/Actions/index.html | 18 +-
.../SPLTokenInstructions.php.html | 2 +-
.../Instructions/TokenInstruction.php.html | 2 +-
.../SplToken/Instructions/dashboard.html | 2 +-
.../Programs/SplToken/Instructions/index.html | 2 +-
.../Programs/SplToken/dashboard.html | 6 +-
.../Programs/SplToken/index.html | 18 +-
.../Programs/SplTokenProgram.php.html | 2 +-
.../Programs/SystemProgram.php.html | 4 +-
build/html-coverage/Programs/dashboard.html | 49 +-
build/html-coverage/Programs/index.html | 56 +--
build/html-coverage/PublicKey.php.html | 84 ++--
build/html-coverage/SolanaRpcClient.php.html | 96 ++--
build/html-coverage/Transaction.php.html | 252 +++++------
.../TransactionInstruction.php.html | 8 +-
build/html-coverage/Util/AccountMeta.php.html | 10 +-
build/html-coverage/Util/Buffer.php.html | 92 ++--
build/html-coverage/Util/Commitment.php.html | 2 +-
.../Util/CompiledInstruction.php.html | 8 +-
.../Util/ConfirmOptions.php.html | 2 +-
.../html-coverage/Util/HasPublicKey.php.html | 2 +-
.../html-coverage/Util/HasSecretKey.php.html | 2 +-
.../html-coverage/Util/MessageHeader.php.html | 8 +-
.../Util/NonceInformation.php.html | 2 +-
build/html-coverage/Util/ShortVec.php.html | 20 +-
.../Util/SignaturePubkeyPair.php.html | 8 +-
build/html-coverage/Util/Signer.php.html | 2 +-
build/html-coverage/Util/dashboard.html | 2 +-
build/html-coverage/Util/index.html | 2 +-
build/html-coverage/dashboard.html | 59 +--
build/html-coverage/index.html | 80 ++--
src/Programs/SNS/Bindings.php | 122 ++++-
src/Programs/SNS/Constants/config.json | 5 +-
.../SNS/Instructions/Instructions.php | 1 +
.../SNS/State/NameRegistryStateAccount.php | 2 +-
.../SNS/State/ReverseInstructionAccount.php | 100 +++++
src/Programs/SNS/Utils.php | 16 +-
src/Programs/SnsProgram.php | 11 +-
src/PublicKey.php | 2 +-
tests/Feature/ConnectionFeatureTest.php | 2 +-
tests/Unit/Programs/Sns/BindingsTest.php | 28 +-
tests/Unit/Programs/Sns/DerivationTest.php | 16 +
90 files changed, 1287 insertions(+), 942 deletions(-)
create mode 100644 src/Programs/SNS/State/ReverseInstructionAccount.php
diff --git a/build/html-coverage/Account.php.html b/build/html-coverage/Account.php.html
index 9d95c4a..56cc752 100644
--- a/build/html-coverage/Account.php.html
+++ b/build/html-coverage/Account.php.html
@@ -188,10 +188,10 @@
15 | |
16 | public function __construct($secretKey = null) |
17 | { |
- 18 | if ($secretKey) { |
- 19 | $secretKeyString = Buffer::from($secretKey)->toString(); |
+ 18 | if ($secretKey) { |
+ 19 | $secretKeyString = Buffer::from($secretKey)->toString(); |
20 | |
- 21 | $this->keypair = Keypair::fromSecretKey($secretKeyString); |
+ 21 | $this->keypair = Keypair::fromSecretKey($secretKeyString); |
22 | } else { |
23 | $this->keypair = Keypair::generate(); |
24 | } |
@@ -202,7 +202,7 @@
29 | |
30 | public function getPublicKey(): PublicKey |
31 | { |
- 32 | return $this->keypair->getPublicKey(); |
+ 32 | return $this->keypair->getPublicKey(); |
33 | } |
34 | |
35 | |
@@ -225,7 +225,7 @@
Legend
Covered by small (and larger) testsCovered by medium (and large) testsCovered by large tests (and tests of unknown size)Not coveredNot coverable
- Generated by php-code-coverage 10.1.14 using PHP 8.3.2 and PHPUnit 10.5.20 at Thu May 9 3:59:51 UTC 2024.
+ Generated by php-code-coverage 10.1.14 using PHP 8.3.2 and PHPUnit 10.5.20 at Thu May 9 9:22:33 UTC 2024.
diff --git a/build/html-coverage/Accounts/Creator.php.html b/build/html-coverage/Accounts/Creator.php.html
index a27333c..abc8849 100644
--- a/build/html-coverage/Accounts/Creator.php.html
+++ b/build/html-coverage/Accounts/Creator.php.html
@@ -107,7 +107,7 @@
Legend
Covered by small (and larger) testsCovered by medium (and large) testsCovered by large tests (and tests of unknown size)Not coveredNot coverable
- Generated by php-code-coverage 10.1.14 using PHP 8.3.2 and PHPUnit 10.5.20 at Thu May 9 3:59:51 UTC 2024.
+ Generated by php-code-coverage 10.1.14 using PHP 8.3.2 and PHPUnit 10.5.20 at Thu May 9 9:22:33 UTC 2024.
diff --git a/build/html-coverage/Accounts/Did/ServiceStruct.php.html b/build/html-coverage/Accounts/Did/ServiceStruct.php.html
index 01b68a1..2cd40ca 100644
--- a/build/html-coverage/Accounts/Did/ServiceStruct.php.html
+++ b/build/html-coverage/Accounts/Did/ServiceStruct.php.html
@@ -122,7 +122,7 @@
Legend
Covered by small (and larger) testsCovered by medium (and large) testsCovered by large tests (and tests of unknown size)Not coveredNot coverable
- Generated by php-code-coverage 10.1.14 using PHP 8.3.2 and PHPUnit 10.5.20 at Thu May 9 3:59:51 UTC 2024.
+ Generated by php-code-coverage 10.1.14 using PHP 8.3.2 and PHPUnit 10.5.20 at Thu May 9 9:22:33 UTC 2024.
diff --git a/build/html-coverage/Accounts/Did/VerificationMethodStruct.php.html b/build/html-coverage/Accounts/Did/VerificationMethodStruct.php.html
index f80901f..3d9f0ee 100644
--- a/build/html-coverage/Accounts/Did/VerificationMethodStruct.php.html
+++ b/build/html-coverage/Accounts/Did/VerificationMethodStruct.php.html
@@ -122,7 +122,7 @@
Legend
Covered by small (and larger) testsCovered by medium (and large) testsCovered by large tests (and tests of unknown size)Not coveredNot coverable
- Generated by php-code-coverage 10.1.14 using PHP 8.3.2 and PHPUnit 10.5.20 at Thu May 9 3:59:51 UTC 2024.
+ Generated by php-code-coverage 10.1.14 using PHP 8.3.2 and PHPUnit 10.5.20 at Thu May 9 9:22:33 UTC 2024.
diff --git a/build/html-coverage/Accounts/Did/dashboard.html b/build/html-coverage/Accounts/Did/dashboard.html
index 3ccecc9..11238a9 100644
--- a/build/html-coverage/Accounts/Did/dashboard.html
+++ b/build/html-coverage/Accounts/Did/dashboard.html
@@ -137,7 +137,7 @@ Project Risks
diff --git a/build/html-coverage/Accounts/Did/index.html b/build/html-coverage/Accounts/Did/index.html
index 489442a..fa605b8 100644
--- a/build/html-coverage/Accounts/Did/index.html
+++ b/build/html-coverage/Accounts/Did/index.html
@@ -95,7 +95,7 @@ Legend
High: 90% to 100%
- Generated by php-code-coverage 10.1.14 using PHP 8.3.2 and PHPUnit 10.5.20 at Thu May 9 3:59:51 UTC 2024.
+ Generated by php-code-coverage 10.1.14 using PHP 8.3.2 and PHPUnit 10.5.20 at Thu May 9 9:22:33 UTC 2024.
diff --git a/build/html-coverage/Accounts/DidData.php.html b/build/html-coverage/Accounts/DidData.php.html
index a7da7d6..7680e32 100644
--- a/build/html-coverage/Accounts/DidData.php.html
+++ b/build/html-coverage/Accounts/DidData.php.html
@@ -195,7 +195,7 @@
Legend
Covered by small (and larger) testsCovered by medium (and large) testsCovered by large tests (and tests of unknown size)Not coveredNot coverable
- Generated by php-code-coverage 10.1.14 using PHP 8.3.2 and PHPUnit 10.5.20 at Thu May 9 3:59:51 UTC 2024.
+ Generated by php-code-coverage 10.1.14 using PHP 8.3.2 and PHPUnit 10.5.20 at Thu May 9 9:22:33 UTC 2024.
diff --git a/build/html-coverage/Accounts/Metadata.php.html b/build/html-coverage/Accounts/Metadata.php.html
index 67fe61f..5e34777 100644
--- a/build/html-coverage/Accounts/Metadata.php.html
+++ b/build/html-coverage/Accounts/Metadata.php.html
@@ -171,7 +171,7 @@
Legend
Covered by small (and larger) testsCovered by medium (and large) testsCovered by large tests (and tests of unknown size)Not coveredNot coverable
- Generated by php-code-coverage 10.1.14 using PHP 8.3.2 and PHPUnit 10.5.20 at Thu May 9 3:59:51 UTC 2024.
+ Generated by php-code-coverage 10.1.14 using PHP 8.3.2 and PHPUnit 10.5.20 at Thu May 9 9:22:33 UTC 2024.
diff --git a/build/html-coverage/Accounts/MetadataData.php.html b/build/html-coverage/Accounts/MetadataData.php.html
index cc57471..f9268f8 100644
--- a/build/html-coverage/Accounts/MetadataData.php.html
+++ b/build/html-coverage/Accounts/MetadataData.php.html
@@ -170,7 +170,7 @@
Legend
Covered by small (and larger) testsCovered by medium (and large) testsCovered by large tests (and tests of unknown size)Not coveredNot coverable
- Generated by php-code-coverage 10.1.14 using PHP 8.3.2 and PHPUnit 10.5.20 at Thu May 9 3:59:51 UTC 2024.
+ Generated by php-code-coverage 10.1.14 using PHP 8.3.2 and PHPUnit 10.5.20 at Thu May 9 9:22:33 UTC 2024.
diff --git a/build/html-coverage/Accounts/Sns/NtfRecordAccount.php.html b/build/html-coverage/Accounts/Sns/NtfRecordAccount.php.html
index e06c47a..73b6ff8 100644
--- a/build/html-coverage/Accounts/Sns/NtfRecordAccount.php.html
+++ b/build/html-coverage/Accounts/Sns/NtfRecordAccount.php.html
@@ -242,7 +242,7 @@
Legend
Covered by small (and larger) testsCovered by medium (and large) testsCovered by large tests (and tests of unknown size)Not coveredNot coverable
- Generated by php-code-coverage 10.1.14 using PHP 8.3.2 and PHPUnit 10.5.20 at Thu May 9 3:59:51 UTC 2024.
+ Generated by php-code-coverage 10.1.14 using PHP 8.3.2 and PHPUnit 10.5.20 at Thu May 9 9:22:33 UTC 2024.
diff --git a/build/html-coverage/Accounts/Sns/dashboard.html b/build/html-coverage/Accounts/Sns/dashboard.html
index 03b2fb5..56f7c6c 100644
--- a/build/html-coverage/Accounts/Sns/dashboard.html
+++ b/build/html-coverage/Accounts/Sns/dashboard.html
@@ -143,7 +143,7 @@ Project Risks
diff --git a/build/html-coverage/Accounts/Sns/index.html b/build/html-coverage/Accounts/Sns/index.html
index 705e5e8..b5779d7 100644
--- a/build/html-coverage/Accounts/Sns/index.html
+++ b/build/html-coverage/Accounts/Sns/index.html
@@ -112,7 +112,7 @@ Legend
High: 90% to 100%
- Generated by php-code-coverage 10.1.14 using PHP 8.3.2 and PHPUnit 10.5.20 at Thu May 9 3:59:51 UTC 2024.
+ Generated by php-code-coverage 10.1.14 using PHP 8.3.2 and PHPUnit 10.5.20 at Thu May 9 9:22:33 UTC 2024.
diff --git a/build/html-coverage/Accounts/dashboard.html b/build/html-coverage/Accounts/dashboard.html
index dcf135f..bc6ba83 100644
--- a/build/html-coverage/Accounts/dashboard.html
+++ b/build/html-coverage/Accounts/dashboard.html
@@ -142,7 +142,7 @@ Project Risks
diff --git a/build/html-coverage/Accounts/index.html b/build/html-coverage/Accounts/index.html
index 14effe6..90a17cc 100644
--- a/build/html-coverage/Accounts/index.html
+++ b/build/html-coverage/Accounts/index.html
@@ -221,7 +221,7 @@ Legend
High: 90% to 100%
- Generated by php-code-coverage 10.1.14 using PHP 8.3.2 and PHPUnit 10.5.20 at Thu May 9 3:59:51 UTC 2024.
+ Generated by php-code-coverage 10.1.14 using PHP 8.3.2 and PHPUnit 10.5.20 at Thu May 9 9:22:33 UTC 2024.
diff --git a/build/html-coverage/Borsh/BinaryReader.php.html b/build/html-coverage/Borsh/BinaryReader.php.html
index 8f36025..e33c385 100644
--- a/build/html-coverage/Borsh/BinaryReader.php.html
+++ b/build/html-coverage/Borsh/BinaryReader.php.html
@@ -540,8 +540,8 @@
14 | |
15 | public function __construct(Buffer $buffer) |
16 | { |
- 17 | $this->buffer = $buffer; |
- 18 | $this->offset = 0; |
+ 17 | $this->buffer = $buffer; |
+ 18 | $this->offset = 0; |
19 | } |
20 | |
21 | |
@@ -549,7 +549,7 @@
23 | |
24 | public function readU8(): int |
25 | { |
- 26 | return $this->readUnsignedInt(1, Buffer::TYPE_BYTE); |
+ 26 | return $this->readUnsignedInt(1, Buffer::TYPE_BYTE); |
27 | } |
28 | |
29 | |
@@ -565,7 +565,7 @@
39 | |
40 | public function readU32(): int |
41 | { |
- 42 | return $this->readUnsignedInt(4, Buffer::TYPE_INT); |
+ 42 | return $this->readUnsignedInt(4, Buffer::TYPE_INT); |
43 | } |
44 | |
45 | |
@@ -614,9 +614,9 @@
88 | |
89 | protected function readUnsignedInt($length, $datatype): int |
90 | { |
- 91 | $value = $this->buffer->slice($this->offset, $length, $datatype, false)->value(); |
- 92 | $this->offset += $length; |
- 93 | return $value; |
+ 91 | $value = $this->buffer->slice($this->offset, $length, $datatype, false)->value(); |
+ 92 | $this->offset += $length; |
+ 93 | return $value; |
94 | } |
95 | |
96 | |
@@ -656,8 +656,8 @@
130 | |
131 | public function readString(): string |
132 | { |
- 133 | $length = $this->readU32(); |
- 134 | return $this->readBuffer($length); |
+ 133 | $length = $this->readU32(); |
+ 134 | return $this->readBuffer($length); |
135 | } |
136 | |
137 | |
@@ -666,12 +666,12 @@
140 | |
141 | public function readFixedArray(int $length): array |
142 | { |
- 143 | return $this->readBuffer($length)->toArray(); |
+ 143 | return $this->readBuffer($length)->toArray(); |
144 | } |
145 | |
146 | public function readPubKey(): PublicKey |
147 | { |
- 148 | return new PublicKey($this->readFixedArray(32)); |
+ 148 | return new PublicKey($this->readFixedArray(32)); |
149 | } |
150 | |
151 | public function readPubKeyAsString(): string |
@@ -699,13 +699,13 @@
173 | |
174 | protected function readBuffer($length): Buffer |
175 | { |
- 176 | if ($this->offset + $length > sizeof($this->buffer)) { |
+ 176 | if ($this->offset + $length > sizeof($this->buffer)) { |
177 | throw new BorshException("Expected buffer length {$length} isn't within bounds"); |
178 | } |
179 | |
- 180 | $buffer = $this->buffer->slice($this->offset, $length); |
- 181 | $this->offset += $length; |
- 182 | return $buffer; |
+ 180 | $buffer = $this->buffer->slice($this->offset, $length); |
+ 181 | $this->offset += $length; |
+ 182 | return $buffer; |
183 | } |
184 | |
185 | } |
@@ -719,7 +719,7 @@
Legend
Covered by small (and larger) testsCovered by medium (and large) testsCovered by large tests (and tests of unknown size)Not coveredNot coverable
- Generated by php-code-coverage 10.1.14 using PHP 8.3.2 and PHPUnit 10.5.20 at Thu May 9 3:59:51 UTC 2024.
+ Generated by php-code-coverage 10.1.14 using PHP 8.3.2 and PHPUnit 10.5.20 at Thu May 9 9:22:33 UTC 2024.
diff --git a/build/html-coverage/Borsh/BinaryWriter.php.html b/build/html-coverage/Borsh/BinaryWriter.php.html
index ab83407..b39f88f 100644
--- a/build/html-coverage/Borsh/BinaryWriter.php.html
+++ b/build/html-coverage/Borsh/BinaryWriter.php.html
@@ -473,8 +473,8 @@
13 | |
14 | public function __construct() |
15 | { |
- 16 | $this->buffer = Buffer::from(); |
- 17 | $this->length = 0; |
+ 16 | $this->buffer = Buffer::from(); |
+ 17 | $this->length = 0; |
18 | } |
19 | |
20 | |
@@ -483,7 +483,7 @@
23 | |
24 | public function writeU8(int $value) |
25 | { |
- 26 | return $this->writeBuffer(Buffer::from($value, Buffer::TYPE_BYTE, false)); |
+ 26 | return $this->writeBuffer(Buffer::from($value, Buffer::TYPE_BYTE, false)); |
27 | } |
28 | |
29 | |
@@ -501,7 +501,7 @@
41 | |
42 | public function writeU32(int $value) |
43 | { |
- 44 | return $this->writeBuffer(Buffer::from($value, Buffer::TYPE_INT, false)); |
+ 44 | return $this->writeBuffer(Buffer::from($value, Buffer::TYPE_INT, false)); |
45 | } |
46 | |
47 | |
@@ -573,10 +573,10 @@
113 | |
114 | public function writeString(string $value) |
115 | { |
- 116 | $valueBuffer = Buffer::from($value); |
- 117 | $this->writeU32(sizeof($valueBuffer)); |
- 118 | $this->writeBuffer($valueBuffer); |
- 119 | return $this; |
+ 116 | $valueBuffer = Buffer::from($value); |
+ 117 | $this->writeU32(sizeof($valueBuffer)); |
+ 118 | $this->writeBuffer($valueBuffer); |
+ 119 | return $this; |
120 | } |
121 | |
122 | |
@@ -608,9 +608,9 @@
148 | |
149 | protected function writeBuffer(Buffer $buffer) |
150 | { |
- 151 | $this->buffer->push($buffer); |
- 152 | $this->length += sizeof($buffer); |
- 153 | return $this; |
+ 151 | $this->buffer->push($buffer); |
+ 152 | $this->length += sizeof($buffer); |
+ 153 | return $this; |
154 | } |
155 | |
156 | |
@@ -618,7 +618,7 @@
158 | |
159 | public function toArray() |
160 | { |
- 161 | return $this->buffer->slice(0, $this->length)->toArray(); |
+ 161 | return $this->buffer->slice(0, $this->length)->toArray(); |
162 | } |
163 | } |
@@ -631,7 +631,7 @@
Legend
Covered by small (and larger) testsCovered by medium (and large) testsCovered by large tests (and tests of unknown size)Not coveredNot coverable
- Generated by php-code-coverage 10.1.14 using PHP 8.3.2 and PHPUnit 10.5.20 at Thu May 9 3:59:51 UTC 2024.
+ Generated by php-code-coverage 10.1.14 using PHP 8.3.2 and PHPUnit 10.5.20 at Thu May 9 9:22:33 UTC 2024.
diff --git a/build/html-coverage/Borsh/Borsh.php.html b/build/html-coverage/Borsh/Borsh.php.html
index 5b1eca9..ebbc5e6 100644
--- a/build/html-coverage/Borsh/Borsh.php.html
+++ b/build/html-coverage/Borsh/Borsh.php.html
@@ -257,9 +257,9 @@
17 | $object |
18 | ) : array |
19 | { |
- 20 | $writer = new BinaryWriter(); |
- 21 | static::serializeObject($schema, $object, $writer); |
- 22 | return $writer->toArray(); |
+ 20 | $writer = new BinaryWriter(); |
+ 21 | static::serializeObject($schema, $object, $writer); |
+ 22 | return $writer->toArray(); |
23 | } |
24 | |
25 | |
@@ -272,15 +272,15 @@
32 | $object, |
33 | BinaryWriter $writer |
34 | ) { |
- 35 | $objectSchema = $schema[get_class($object)] ?? null; |
- 36 | if (! $objectSchema) { |
+ 35 | $objectSchema = $schema[get_class($object)] ?? null; |
+ 36 | if (! $objectSchema) { |
37 | $class = get_class($object); |
38 | throw new BorshException("Class {$class} is missing in schema"); |
39 | } |
40 | |
- 41 | if ($objectSchema['kind'] === 'struct') { |
- 42 | foreach ($objectSchema['fields'] as list($fieldName, $fieldType)) { |
- 43 | static::serializeField($schema, $fieldName, $object->{$fieldName}, $fieldType, $writer); |
+ 41 | if ($objectSchema['kind'] === 'struct') { |
+ 42 | foreach ($objectSchema['fields'] as list($fieldName, $fieldType)) { |
+ 43 | static::serializeField($schema, $fieldName, $object->{$fieldName}, $fieldType, $writer); |
44 | } |
45 | } elseif ($objectSchema['kind'] === 'enum') { |
46 | throw new TodoException("TODO: Enums don't exist in PHP yet???"); |
@@ -305,10 +305,10 @@
65 | $fieldType, |
66 | BinaryWriter $writer |
67 | ) { |
- 68 | if (is_string($fieldType)) { |
- 69 | $writer->{'write' . ucfirst($fieldType)}($value); |
- 70 | } elseif (is_array($fieldType) && isset($fieldType[0])) { |
- 71 | if (is_int($fieldType[0])) { |
+ 68 | if (is_string($fieldType)) { |
+ 69 | $writer->{'write' . ucfirst($fieldType)}($value); |
+ 70 | } elseif (is_array($fieldType) && isset($fieldType[0])) { |
+ 71 | if (is_int($fieldType[0])) { |
72 | if (sizeof($value) !== $fieldType[0]) { |
73 | $sizeOf = sizeof($value); |
74 | throw new BorshException("Expecting byte array of length {{$fieldType[0]}}, but got {{$sizeOf}} bytes"); |
@@ -357,8 +357,8 @@
117 | array $buffer |
118 | ) |
119 | { |
- 120 | $reader = new BinaryReader(Buffer::from($buffer)); |
- 121 | return static::deserializeObject($schema, $class, $reader); |
+ 120 | $reader = new BinaryReader(Buffer::from($buffer)); |
+ 121 | return static::deserializeObject($schema, $class, $reader); |
122 | } |
123 | |
124 | |
@@ -371,22 +371,22 @@
131 | string $class, |
132 | BinaryReader $reader |
133 | ) { |
- 134 | $objectSchema = $schema[$class] ?? null; |
- 135 | if (! $objectSchema) { |
+ 134 | $objectSchema = $schema[$class] ?? null; |
+ 135 | if (! $objectSchema) { |
136 | throw new BorshException("Class {$class} is missing in schema"); |
137 | } |
138 | |
- 139 | if ($objectSchema['kind'] === 'struct') { |
- 140 | if (! method_exists($class, 'borshConstructor')) { |
+ 139 | if ($objectSchema['kind'] === 'struct') { |
+ 140 | if (! method_exists($class, 'borshConstructor')) { |
141 | throw new BorshException("Class {{$class}} does not implement borshConstructor. Please use the BorshDeserialize trait."); |
142 | } |
143 | |
- 144 | $result = $class::borshConstructor(); |
- 145 | foreach ($objectSchema['fields'] as list($fieldName, $fieldType)) { |
- 146 | $result->{$fieldName} = static::deserializeField($schema, $fieldName, $fieldType, $reader); |
+ 144 | $result = $class::borshConstructor(); |
+ 145 | foreach ($objectSchema['fields'] as list($fieldName, $fieldType)) { |
+ 146 | $result->{$fieldName} = static::deserializeField($schema, $fieldName, $fieldType, $reader); |
147 | |
148 | } |
- 149 | return $result; |
+ 149 | return $result; |
150 | } |
151 | |
152 | if ($objectSchema['kind'] === 'enum') { |
@@ -409,12 +409,12 @@
169 | $fieldType, |
170 | BinaryReader $reader |
171 | ) { |
- 172 | if (is_string($fieldType) && ! class_exists($fieldType)) { |
- 173 | return $reader->{'read' . ucfirst($fieldType)}(); |
+ 172 | if (is_string($fieldType) && ! class_exists($fieldType)) { |
+ 173 | return $reader->{'read' . ucfirst($fieldType)}(); |
174 | } |
175 | |
- 176 | if (is_array($fieldType) && isset($fieldType[0])) { |
- 177 | if (is_int($fieldType[0])) { |
+ 176 | if (is_array($fieldType) && isset($fieldType[0])) { |
+ 177 | if (is_int($fieldType[0])) { |
178 | return $reader->readFixedArray($fieldType[0]); |
179 | } elseif (sizeof($fieldType) === 2 && is_int($fieldType[1])) { |
180 | $array = []; |
@@ -449,7 +449,7 @@
Legend
Covered by small (and larger) testsCovered by medium (and large) testsCovered by large tests (and tests of unknown size)Not coveredNot coverable
- Generated by php-code-coverage 10.1.14 using PHP 8.3.2 and PHPUnit 10.5.20 at Thu May 9 3:59:51 UTC 2024.
+ Generated by php-code-coverage 10.1.14 using PHP 8.3.2 and PHPUnit 10.5.20 at Thu May 9 9:22:33 UTC 2024.
diff --git a/build/html-coverage/Borsh/BorshDeserializable.php.html b/build/html-coverage/Borsh/BorshDeserializable.php.html
index 319fa0e..461f43e 100644
--- a/build/html-coverage/Borsh/BorshDeserializable.php.html
+++ b/build/html-coverage/Borsh/BorshDeserializable.php.html
@@ -230,7 +230,7 @@
12 | |
13 | public static function borshConstructor() |
14 | { |
- 15 | return new static(); |
+ 15 | return new static(); |
16 | } |
17 | |
18 | |
@@ -242,17 +242,17 @@
24 | public function __set(string $name, mixed $value) |
25 | { |
26 | |
- 27 | if (!$this->isPrivateProperty($name)) { |
- 28 | $this->fields[$name] = $value; |
+ 27 | if (!$this->isPrivateProperty($name)) { |
+ 28 | $this->fields[$name] = $value; |
29 | } |
30 | |
31 | |
- 32 | if ($this->isPrivateProperty($name)) { |
+ 32 | if ($this->isPrivateProperty($name)) { |
33 | |
- 34 | $reflectionClass = new ReflectionClass($this); |
- 35 | $property = $reflectionClass->getProperty($name); |
- 36 | $property->setAccessible(true); |
- 37 | $property->setValue($this, $value); |
+ 34 | $reflectionClass = new ReflectionClass($this); |
+ 35 | $property = $reflectionClass->getProperty($name); |
+ 36 | $property->setAccessible(true); |
+ 37 | $property->setValue($this, $value); |
38 | } |
39 | } |
40 | |
@@ -292,13 +292,13 @@
74 | private function isPrivateProperty(string $name): bool |
75 | { |
76 | |
- 77 | $className = static::class; |
+ 77 | $className = static::class; |
78 | |
79 | |
- 80 | $reflectionClass = new ReflectionClass($className); |
+ 80 | $reflectionClass = new ReflectionClass($className); |
81 | |
82 | |
- 83 | return $reflectionClass->hasProperty($name) && $reflectionClass->getProperty($name)->isPrivate(); |
+ 83 | return $reflectionClass->hasProperty($name) && $reflectionClass->getProperty($name)->isPrivate(); |
84 | } |
85 | } |
@@ -311,7 +311,7 @@
Legend
Covered by small (and larger) testsCovered by medium (and large) testsCovered by large tests (and tests of unknown size)Not coveredNot coverable
- Generated by php-code-coverage 10.1.14 using PHP 8.3.2 and PHPUnit 10.5.20 at Thu May 9 3:59:51 UTC 2024.
+ Generated by php-code-coverage 10.1.14 using PHP 8.3.2 and PHPUnit 10.5.20 at Thu May 9 9:22:33 UTC 2024.
diff --git a/build/html-coverage/Borsh/BorshException.php.html b/build/html-coverage/Borsh/BorshException.php.html
index fa284bb..3548ba2 100644
--- a/build/html-coverage/Borsh/BorshException.php.html
+++ b/build/html-coverage/Borsh/BorshException.php.html
@@ -96,7 +96,7 @@
Legend
Covered by small (and larger) testsCovered by medium (and large) testsCovered by large tests (and tests of unknown size)Not coveredNot coverable
- Generated by php-code-coverage 10.1.14 using PHP 8.3.2 and PHPUnit 10.5.20 at Thu May 9 3:59:51 UTC 2024.
+ Generated by php-code-coverage 10.1.14 using PHP 8.3.2 and PHPUnit 10.5.20 at Thu May 9 9:22:33 UTC 2024.
diff --git a/build/html-coverage/Borsh/BorshObject.php.html b/build/html-coverage/Borsh/BorshObject.php.html
index 0878c9e..f077a76 100644
--- a/build/html-coverage/Borsh/BorshObject.php.html
+++ b/build/html-coverage/Borsh/BorshObject.php.html
@@ -102,7 +102,7 @@
Legend
Covered by small (and larger) testsCovered by medium (and large) testsCovered by large tests (and tests of unknown size)Not coveredNot coverable
- Generated by php-code-coverage 10.1.14 using PHP 8.3.2 and PHPUnit 10.5.20 at Thu May 9 3:59:51 UTC 2024.
+ Generated by php-code-coverage 10.1.14 using PHP 8.3.2 and PHPUnit 10.5.20 at Thu May 9 9:22:33 UTC 2024.
diff --git a/build/html-coverage/Borsh/BorshSerializable.php.html b/build/html-coverage/Borsh/BorshSerializable.php.html
index 6460b69..ebf9661 100644
--- a/build/html-coverage/Borsh/BorshSerializable.php.html
+++ b/build/html-coverage/Borsh/BorshSerializable.php.html
@@ -147,17 +147,17 @@
17 | public function __get(string $name) |
18 | { |
19 | |
- 20 | if (array_key_exists($name, $this->fields)) { |
- 21 | return $this->fields[$name]; |
+ 20 | if (array_key_exists($name, $this->fields)) { |
+ 21 | return $this->fields[$name]; |
22 | } |
23 | |
24 | |
- 25 | if ($this->isPrivateProperty($name)) { |
+ 25 | if ($this->isPrivateProperty($name)) { |
26 | |
- 27 | $reflectionClass = new ReflectionClass($this); |
- 28 | $property = $reflectionClass->getProperty($name); |
- 29 | $property->setAccessible(true); |
- 30 | return $property->getValue($this); |
+ 27 | $reflectionClass = new ReflectionClass($this); |
+ 28 | $property = $reflectionClass->getProperty($name); |
+ 29 | $property->setAccessible(true); |
+ 30 | return $property->getValue($this); |
31 | } |
32 | |
33 | |
@@ -174,7 +174,7 @@
Legend
Covered by small (and larger) testsCovered by medium (and large) testsCovered by large tests (and tests of unknown size)Not coveredNot coverable
- Generated by php-code-coverage 10.1.14 using PHP 8.3.2 and PHPUnit 10.5.20 at Thu May 9 3:59:51 UTC 2024.
+ Generated by php-code-coverage 10.1.14 using PHP 8.3.2 and PHPUnit 10.5.20 at Thu May 9 9:22:33 UTC 2024.
diff --git a/build/html-coverage/Borsh/dashboard.html b/build/html-coverage/Borsh/dashboard.html
index ed4cafd..9704ef7 100644
--- a/build/html-coverage/Borsh/dashboard.html
+++ b/build/html-coverage/Borsh/dashboard.html
@@ -169,7 +169,7 @@ Project Risks
diff --git a/build/html-coverage/Borsh/index.html b/build/html-coverage/Borsh/index.html
index f1b2269..ea91b5a 100644
--- a/build/html-coverage/Borsh/index.html
+++ b/build/html-coverage/Borsh/index.html
@@ -249,7 +249,7 @@ Legend
High: 90% to 100%
- Generated by php-code-coverage 10.1.14 using PHP 8.3.2 and PHPUnit 10.5.20 at Thu May 9 3:59:51 UTC 2024.
+ Generated by php-code-coverage 10.1.14 using PHP 8.3.2 and PHPUnit 10.5.20 at Thu May 9 9:22:33 UTC 2024.
diff --git a/build/html-coverage/Connection.php.html b/build/html-coverage/Connection.php.html
index bf54f45..03646c8 100644
--- a/build/html-coverage/Connection.php.html
+++ b/build/html-coverage/Connection.php.html
@@ -44,21 +44,21 @@
Total |
-
- 63.16% covered (warning)
+
+ 64.10% covered (warning)
|
- 63.16% |
- 24 / 38 |
+ 64.10% |
+ 25 / 39 |
-
- 70.00% covered (warning)
+
+ 72.73% covered (warning)
|
- 70.00% |
- 7 / 10 |
+ 72.73% |
+ 8 / 11 |
CRAP |
@@ -73,22 +73,22 @@
Connection |
-
- 63.16% covered (warning)
+
+ 64.10% covered (warning)
|
- 63.16% |
- 24 / 38 |
+ 64.10% |
+ 25 / 39 |
-
- 70.00% covered (warning)
+
+ 72.73% covered (warning)
|
- 70.00% |
- 7 / 10 |
- 23.80 |
+ 72.73% |
+ 8 / 11 |
+ 25.41 |
0.00% covered (danger)
@@ -319,6 +319,28 @@
|
|
+
+ getMinimumBalanceForRentExemption |
+
+
+ 100.00% covered (success)
+
+
+ |
+ 100.00% |
+ 1 / 1 |
+
+
+ 100.00% covered (success)
+
+
+ |
+ 100.00% |
+ 1 / 1 |
+ 1 |
+ |
+
+
@@ -351,13 +373,13 @@
24 | |
25 | public function getAccountInfo(string $pubKey): array |
26 | { |
- 27 | $accountResponse = $this->client->call('getAccountInfo', [$pubKey, ["encoding" => "base64"]])['value']; |
+ 27 | $accountResponse = $this->client->call('getAccountInfo', [$pubKey, ["encoding" => "base64"]])['value']; |
28 | |
- 29 | if (! $accountResponse) { |
+ 29 | if (! $accountResponse) { |
30 | throw new AccountNotFoundException("API Error: Account {$pubKey} not found."); |
31 | } |
32 | |
- 33 | return $accountResponse; |
+ 33 | return $accountResponse; |
34 | } |
35 | |
36 | |
@@ -499,7 +521,11 @@
172 | |
173 | } |
174 | |
- 175 | } |
+ 175 | public function getMinimumBalanceForRentExemption(int $space = 1024){ |
+ 176 | return $this->client->call('getMinimumBalanceForRentExemption', [$space] ); |
+ 177 | } |
+ 178 | |
+ 179 | } |
@@ -510,7 +536,7 @@
Legend
Covered by small (and larger) testsCovered by medium (and large) testsCovered by large tests (and tests of unknown size)Not coveredNot coverable
- Generated by php-code-coverage 10.1.14 using PHP 8.3.2 and PHPUnit 10.5.20 at Thu May 9 3:59:51 UTC 2024.
+ Generated by php-code-coverage 10.1.14 using PHP 8.3.2 and PHPUnit 10.5.20 at Thu May 9 9:22:33 UTC 2024.
diff --git a/build/html-coverage/Exceptions/AccountNotFoundException.php.html b/build/html-coverage/Exceptions/AccountNotFoundException.php.html
index 83ec877..4e19d18 100644
--- a/build/html-coverage/Exceptions/AccountNotFoundException.php.html
+++ b/build/html-coverage/Exceptions/AccountNotFoundException.php.html
@@ -96,7 +96,7 @@
Legend
Covered by small (and larger) testsCovered by medium (and large) testsCovered by large tests (and tests of unknown size)Not coveredNot coverable
- Generated by php-code-coverage 10.1.14 using PHP 8.3.2 and PHPUnit 10.5.20 at Thu May 9 3:59:51 UTC 2024.
+ Generated by php-code-coverage 10.1.14 using PHP 8.3.2 and PHPUnit 10.5.20 at Thu May 9 9:22:33 UTC 2024.
diff --git a/build/html-coverage/Exceptions/BaseSolanaPhpSdkException.php.html b/build/html-coverage/Exceptions/BaseSolanaPhpSdkException.php.html
index 41707ba..7311e2b 100644
--- a/build/html-coverage/Exceptions/BaseSolanaPhpSdkException.php.html
+++ b/build/html-coverage/Exceptions/BaseSolanaPhpSdkException.php.html
@@ -96,7 +96,7 @@
Legend
Covered by small (and larger) testsCovered by medium (and large) testsCovered by large tests (and tests of unknown size)Not coveredNot coverable
- Generated by php-code-coverage 10.1.14 using PHP 8.3.2 and PHPUnit 10.5.20 at Thu May 9 3:59:51 UTC 2024.
+ Generated by php-code-coverage 10.1.14 using PHP 8.3.2 and PHPUnit 10.5.20 at Thu May 9 9:22:33 UTC 2024.
diff --git a/build/html-coverage/Exceptions/GenericException.php.html b/build/html-coverage/Exceptions/GenericException.php.html
index 42c230f..4dd102c 100644
--- a/build/html-coverage/Exceptions/GenericException.php.html
+++ b/build/html-coverage/Exceptions/GenericException.php.html
@@ -96,7 +96,7 @@
Legend
Covered by small (and larger) testsCovered by medium (and large) testsCovered by large tests (and tests of unknown size)Not coveredNot coverable
- Generated by php-code-coverage 10.1.14 using PHP 8.3.2 and PHPUnit 10.5.20 at Thu May 9 3:59:51 UTC 2024.
+ Generated by php-code-coverage 10.1.14 using PHP 8.3.2 and PHPUnit 10.5.20 at Thu May 9 9:22:33 UTC 2024.
diff --git a/build/html-coverage/Exceptions/InputValidationException.php.html b/build/html-coverage/Exceptions/InputValidationException.php.html
index d8872b1..4bb54dc 100644
--- a/build/html-coverage/Exceptions/InputValidationException.php.html
+++ b/build/html-coverage/Exceptions/InputValidationException.php.html
@@ -94,7 +94,7 @@
Legend
Covered by small (and larger) testsCovered by medium (and large) testsCovered by large tests (and tests of unknown size)Not coveredNot coverable
- Generated by php-code-coverage 10.1.14 using PHP 8.3.2 and PHPUnit 10.5.20 at Thu May 9 3:59:51 UTC 2024.
+ Generated by php-code-coverage 10.1.14 using PHP 8.3.2 and PHPUnit 10.5.20 at Thu May 9 9:22:33 UTC 2024.
diff --git a/build/html-coverage/Exceptions/InvalidIdResponseException.php.html b/build/html-coverage/Exceptions/InvalidIdResponseException.php.html
index f52163c..330001f 100644
--- a/build/html-coverage/Exceptions/InvalidIdResponseException.php.html
+++ b/build/html-coverage/Exceptions/InvalidIdResponseException.php.html
@@ -96,7 +96,7 @@
Legend
Covered by small (and larger) testsCovered by medium (and large) testsCovered by large tests (and tests of unknown size)Not coveredNot coverable
- Generated by php-code-coverage 10.1.14 using PHP 8.3.2 and PHPUnit 10.5.20 at Thu May 9 3:59:51 UTC 2024.
+ Generated by php-code-coverage 10.1.14 using PHP 8.3.2 and PHPUnit 10.5.20 at Thu May 9 9:22:33 UTC 2024.
diff --git a/build/html-coverage/Exceptions/MethodNotFoundException.php.html b/build/html-coverage/Exceptions/MethodNotFoundException.php.html
index 3eda931..ff60cd1 100644
--- a/build/html-coverage/Exceptions/MethodNotFoundException.php.html
+++ b/build/html-coverage/Exceptions/MethodNotFoundException.php.html
@@ -96,7 +96,7 @@
Legend
Covered by small (and larger) testsCovered by medium (and large) testsCovered by large tests (and tests of unknown size)Not coveredNot coverable
- Generated by php-code-coverage 10.1.14 using PHP 8.3.2 and PHPUnit 10.5.20 at Thu May 9 3:59:51 UTC 2024.
+ Generated by php-code-coverage 10.1.14 using PHP 8.3.2 and PHPUnit 10.5.20 at Thu May 9 9:22:33 UTC 2024.
diff --git a/build/html-coverage/Exceptions/SNSError.php.html b/build/html-coverage/Exceptions/SNSError.php.html
index c667e9a..86e3292 100644
--- a/build/html-coverage/Exceptions/SNSError.php.html
+++ b/build/html-coverage/Exceptions/SNSError.php.html
@@ -187,7 +187,7 @@
Legend
Covered by small (and larger) testsCovered by medium (and large) testsCovered by large tests (and tests of unknown size)Not coveredNot coverable
- Generated by php-code-coverage 10.1.14 using PHP 8.3.2 and PHPUnit 10.5.20 at Thu May 9 3:59:51 UTC 2024.
+ Generated by php-code-coverage 10.1.14 using PHP 8.3.2 and PHPUnit 10.5.20 at Thu May 9 9:22:33 UTC 2024.
diff --git a/build/html-coverage/Exceptions/TodoException.php.html b/build/html-coverage/Exceptions/TodoException.php.html
index 058bea9..2b58dac 100644
--- a/build/html-coverage/Exceptions/TodoException.php.html
+++ b/build/html-coverage/Exceptions/TodoException.php.html
@@ -152,7 +152,7 @@
Legend
Covered by small (and larger) testsCovered by medium (and large) testsCovered by large tests (and tests of unknown size)Not coveredNot coverable
- Generated by php-code-coverage 10.1.14 using PHP 8.3.2 and PHPUnit 10.5.20 at Thu May 9 3:59:51 UTC 2024.
+ Generated by php-code-coverage 10.1.14 using PHP 8.3.2 and PHPUnit 10.5.20 at Thu May 9 9:22:33 UTC 2024.
diff --git a/build/html-coverage/Exceptions/TokenAccountNotFoundError.php.html b/build/html-coverage/Exceptions/TokenAccountNotFoundError.php.html
index 7f3eab1..242b328 100644
--- a/build/html-coverage/Exceptions/TokenAccountNotFoundError.php.html
+++ b/build/html-coverage/Exceptions/TokenAccountNotFoundError.php.html
@@ -95,7 +95,7 @@
Legend
Covered by small (and larger) testsCovered by medium (and large) testsCovered by large tests (and tests of unknown size)Not coveredNot coverable
- Generated by php-code-coverage 10.1.14 using PHP 8.3.2 and PHPUnit 10.5.20 at Thu May 9 3:59:51 UTC 2024.
+ Generated by php-code-coverage 10.1.14 using PHP 8.3.2 and PHPUnit 10.5.20 at Thu May 9 9:22:33 UTC 2024.
diff --git a/build/html-coverage/Exceptions/TokenInvalidAccountOwnerError.php.html b/build/html-coverage/Exceptions/TokenInvalidAccountOwnerError.php.html
index 0e79054..876b67f 100644
--- a/build/html-coverage/Exceptions/TokenInvalidAccountOwnerError.php.html
+++ b/build/html-coverage/Exceptions/TokenInvalidAccountOwnerError.php.html
@@ -95,7 +95,7 @@
Legend
Covered by small (and larger) testsCovered by medium (and large) testsCovered by large tests (and tests of unknown size)Not coveredNot coverable
- Generated by php-code-coverage 10.1.14 using PHP 8.3.2 and PHPUnit 10.5.20 at Thu May 9 3:59:51 UTC 2024.
+ Generated by php-code-coverage 10.1.14 using PHP 8.3.2 and PHPUnit 10.5.20 at Thu May 9 9:22:33 UTC 2024.
diff --git a/build/html-coverage/Exceptions/TokenInvalidMintError.php.html b/build/html-coverage/Exceptions/TokenInvalidMintError.php.html
index bd0b533..c44c90f 100644
--- a/build/html-coverage/Exceptions/TokenInvalidMintError.php.html
+++ b/build/html-coverage/Exceptions/TokenInvalidMintError.php.html
@@ -96,7 +96,7 @@
Legend
Covered by small (and larger) testsCovered by medium (and large) testsCovered by large tests (and tests of unknown size)Not coveredNot coverable
- Generated by php-code-coverage 10.1.14 using PHP 8.3.2 and PHPUnit 10.5.20 at Thu May 9 3:59:51 UTC 2024.
+ Generated by php-code-coverage 10.1.14 using PHP 8.3.2 and PHPUnit 10.5.20 at Thu May 9 9:22:33 UTC 2024.
diff --git a/build/html-coverage/Exceptions/TokenOwnerOffCurveError.php.html b/build/html-coverage/Exceptions/TokenOwnerOffCurveError.php.html
index a5453cd..b8c45a7 100644
--- a/build/html-coverage/Exceptions/TokenOwnerOffCurveError.php.html
+++ b/build/html-coverage/Exceptions/TokenOwnerOffCurveError.php.html
@@ -95,7 +95,7 @@
Legend
Covered by small (and larger) testsCovered by medium (and large) testsCovered by large tests (and tests of unknown size)Not coveredNot coverable
- Generated by php-code-coverage 10.1.14 using PHP 8.3.2 and PHPUnit 10.5.20 at Thu May 9 3:59:51 UTC 2024.
+ Generated by php-code-coverage 10.1.14 using PHP 8.3.2 and PHPUnit 10.5.20 at Thu May 9 9:22:33 UTC 2024.
diff --git a/build/html-coverage/Exceptions/dashboard.html b/build/html-coverage/Exceptions/dashboard.html
index 5a90f3d..46b0c94 100644
--- a/build/html-coverage/Exceptions/dashboard.html
+++ b/build/html-coverage/Exceptions/dashboard.html
@@ -140,7 +140,7 @@ Project Risks
diff --git a/build/html-coverage/Exceptions/index.html b/build/html-coverage/Exceptions/index.html
index 4df152e..cbcd7d8 100644
--- a/build/html-coverage/Exceptions/index.html
+++ b/build/html-coverage/Exceptions/index.html
@@ -269,7 +269,7 @@ Legend
High: 90% to 100%
- Generated by php-code-coverage 10.1.14 using PHP 8.3.2 and PHPUnit 10.5.20 at Thu May 9 3:59:51 UTC 2024.
+ Generated by php-code-coverage 10.1.14 using PHP 8.3.2 and PHPUnit 10.5.20 at Thu May 9 9:22:33 UTC 2024.
diff --git a/build/html-coverage/Keypair.php.html b/build/html-coverage/Keypair.php.html
index 5be021f..cda0459 100644
--- a/build/html-coverage/Keypair.php.html
+++ b/build/html-coverage/Keypair.php.html
@@ -282,7 +282,7 @@
| 21 | |
22 | public function __construct($publicKey = null, $secretKey = null) |
23 | { |
- 24 | if ($publicKey == null && $secretKey == null) { |
+ 24 | if ($publicKey == null && $secretKey == null) { |
25 | $keypair = sodium_crypto_sign_keypair(); |
26 | |
27 | $publicKey = sodium_crypto_sign_publickey($keypair); |
@@ -291,8 +291,8 @@
30 | |
31 | |
32 | |
- 33 | $this->publicKey = new PublicKey($publicKey); |
- 34 | $this->secretKey = new Buffer($secretKey); |
+ 33 | $this->publicKey = new PublicKey($publicKey); |
+ 34 | $this->secretKey = new Buffer($secretKey); |
35 | } |
36 | |
37 | |
@@ -301,9 +301,9 @@
40 | |
41 | public static function generate(): Keypair |
42 | { |
- 43 | $keypair = sodium_crypto_sign_keypair(); |
+ 43 | $keypair = sodium_crypto_sign_keypair(); |
44 | |
- 45 | return static::from($keypair); |
+ 45 | return static::from($keypair); |
46 | } |
47 | |
48 | |
@@ -313,10 +313,10 @@
52 | |
53 | public static function from(string $keypair): Keypair |
54 | { |
- 55 | return new static( |
- 56 | sodium_crypto_sign_publickey($keypair), |
- 57 | sodium_crypto_sign_secretkey($keypair) |
- 58 | ); |
+ 55 | return new static( |
+ 56 | sodium_crypto_sign_publickey($keypair), |
+ 57 | sodium_crypto_sign_secretkey($keypair) |
+ 58 | ); |
59 | } |
60 | |
61 | |
@@ -331,14 +331,14 @@
70 | |
71 | static public function fromSecretKey($secretKey, $skipValidation = null): Keypair |
72 | { |
- 73 | $secretKey = Buffer::from($secretKey)->toString(); |
+ 73 | $secretKey = Buffer::from($secretKey)->toString(); |
74 | |
- 75 | $publicKey = sodium_crypto_sign_publickey_from_secretkey($secretKey); |
+ 75 | $publicKey = sodium_crypto_sign_publickey_from_secretkey($secretKey); |
76 | |
- 77 | return new static( |
- 78 | $publicKey, |
- 79 | $secretKey |
- 80 | ); |
+ 77 | return new static( |
+ 78 | $publicKey, |
+ 79 | $secretKey |
+ 80 | ); |
81 | } |
82 | |
83 | |
@@ -364,7 +364,7 @@
103 | |
104 | public function getPublicKey(): PublicKey |
105 | { |
- 106 | return $this->publicKey; |
+ 106 | return $this->publicKey; |
107 | } |
108 | |
109 | |
@@ -374,7 +374,7 @@
113 | |
114 | public function getSecretKey(): Buffer |
115 | { |
- 116 | return Buffer::from($this->secretKey); |
+ 116 | return Buffer::from($this->secretKey); |
117 | } |
118 | } |
@@ -387,7 +387,7 @@
Legend
Covered by small (and larger) testsCovered by medium (and large) testsCovered by large tests (and tests of unknown size)Not coveredNot coverable
- Generated by php-code-coverage 10.1.14 using PHP 8.3.2 and PHPUnit 10.5.20 at Thu May 9 3:59:51 UTC 2024.
+ Generated by php-code-coverage 10.1.14 using PHP 8.3.2 and PHPUnit 10.5.20 at Thu May 9 9:22:33 UTC 2024.
diff --git a/build/html-coverage/Message.php.html b/build/html-coverage/Message.php.html
index 83b713d..90bcd33 100644
--- a/build/html-coverage/Message.php.html
+++ b/build/html-coverage/Message.php.html
@@ -368,17 +368,17 @@
41 | array $instructions |
42 | ) |
43 | { |
- 44 | $this->header = $header; |
- 45 | $this->accountKeys = array_map(function (string $accountKey) { |
- 46 | return new PublicKey($accountKey); |
- 47 | }, $accountKeys); |
- 48 | $this->recentBlockhash = $recentBlockhash; |
- 49 | $this->instructions = $instructions; |
+ 44 | $this->header = $header; |
+ 45 | $this->accountKeys = array_map(function (string $accountKey) { |
+ 46 | return new PublicKey($accountKey); |
+ 47 | }, $accountKeys); |
+ 48 | $this->recentBlockhash = $recentBlockhash; |
+ 49 | $this->instructions = $instructions; |
50 | |
- 51 | $this->indexToProgramIds = []; |
+ 51 | $this->indexToProgramIds = []; |
52 | |
- 53 | foreach ($instructions as $instruction) { |
- 54 | $this->indexToProgramIds[$instruction->programIdIndex] = $this->accountKeys[$instruction->programIdIndex]; |
+ 53 | foreach ($instructions as $instruction) { |
+ 54 | $this->indexToProgramIds[$instruction->programIdIndex] = $this->accountKeys[$instruction->programIdIndex]; |
55 | } |
56 | } |
57 | |
@@ -433,17 +433,17 @@
106 | |
107 | public function serialize(): string |
108 | { |
- 109 | $out = new Buffer(); |
+ 109 | $out = new Buffer(); |
110 | |
- 111 | $out->push($this->encodeMessage()) |
- 112 | ->push(ShortVec::encodeLength(sizeof($this->instructions))) |
- 113 | ; |
+ 111 | $out->push($this->encodeMessage()) |
+ 112 | ->push(ShortVec::encodeLength(sizeof($this->instructions))) |
+ 113 | ; |
114 | |
- 115 | foreach ($this->instructions as $instruction) { |
- 116 | $out->push($this->encodeInstruction($instruction)); |
+ 115 | foreach ($this->instructions as $instruction) { |
+ 116 | $out->push($this->encodeInstruction($instruction)); |
117 | } |
118 | |
- 119 | return $out; |
+ 119 | return $out; |
120 | } |
121 | |
122 | |
@@ -451,42 +451,42 @@
124 | |
125 | protected function encodeMessage(): array |
126 | { |
- 127 | $publicKeys = []; |
+ 127 | $publicKeys = []; |
128 | |
- 129 | foreach ($this->accountKeys as $publicKey) { |
- 130 | array_push($publicKeys, ...$publicKey->toBytes()); |
+ 129 | foreach ($this->accountKeys as $publicKey) { |
+ 130 | array_push($publicKeys, ...$publicKey->toBytes()); |
131 | } |
132 | |
- 133 | return [ |
+ 133 | return [ |
134 | |
- 135 | ...unpack("C*", pack("C", $this->header->numRequiredSignature)), |
+ 135 | ...unpack("C*", pack("C", $this->header->numRequiredSignature)), |
136 | |
- 137 | ...unpack("C*", pack("C", $this->header->numReadonlySignedAccounts)), |
+ 137 | ...unpack("C*", pack("C", $this->header->numReadonlySignedAccounts)), |
138 | |
- 139 | ...unpack("C*", pack("C", $this->header->numReadonlyUnsignedAccounts)), |
+ 139 | ...unpack("C*", pack("C", $this->header->numReadonlyUnsignedAccounts)), |
140 | |
- 141 | ...ShortVec::encodeLength(sizeof($this->accountKeys)), |
- 142 | ...$publicKeys, |
- 143 | ...Buffer::fromBase58($this->recentBlockhash)->toArray(), |
- 144 | ]; |
+ 141 | ...ShortVec::encodeLength(sizeof($this->accountKeys)), |
+ 142 | ...$publicKeys, |
+ 143 | ...Buffer::fromBase58($this->recentBlockhash)->toArray(), |
+ 144 | ]; |
145 | } |
146 | |
147 | protected function encodeInstruction(CompiledInstruction $instruction): array |
148 | { |
- 149 | $data = $instruction->data; |
+ 149 | $data = $instruction->data; |
150 | |
- 151 | $accounts = $instruction->accounts;; |
+ 151 | $accounts = $instruction->accounts;; |
152 | |
- 153 | return [ |
+ 153 | return [ |
154 | |
- 155 | ...unpack("C*", pack("C", $instruction->programIdIndex)), |
+ 155 | ...unpack("C*", pack("C", $instruction->programIdIndex)), |
156 | |
- 157 | ...ShortVec::encodeLength(sizeof($accounts)), |
- 158 | ...$accounts, |
+ 157 | ...ShortVec::encodeLength(sizeof($accounts)), |
+ 158 | ...$accounts, |
159 | |
- 160 | ...ShortVec::encodeLength(sizeof($data)), |
- 161 | ...$data->toArray(), |
- 162 | ]; |
+ 160 | ...ShortVec::encodeLength(sizeof($data)), |
+ 161 | ...$data->toArray(), |
+ 162 | ]; |
163 | } |
164 | |
165 | |
@@ -556,7 +556,7 @@
Legend
Covered by small (and larger) testsCovered by medium (and large) testsCovered by large tests (and tests of unknown size)Not coveredNot coverable
- Generated by php-code-coverage 10.1.14 using PHP 8.3.2 and PHPUnit 10.5.20 at Thu May 9 3:59:51 UTC 2024.
+ Generated by php-code-coverage 10.1.14 using PHP 8.3.2 and PHPUnit 10.5.20 at Thu May 9 9:22:33 UTC 2024.
diff --git a/build/html-coverage/Program.php.html b/build/html-coverage/Program.php.html
index 4240620..537f6a9 100644
--- a/build/html-coverage/Program.php.html
+++ b/build/html-coverage/Program.php.html
@@ -163,8 +163,8 @@
12 | |
13 | public function __construct(SolanaRpcClient $client) |
14 | { |
- 15 | $this->client = $client; |
- 16 | $this->config = require __DIR__ . '/../config/solana-sdk.php'; |
+ 15 | $this->client = $client; |
+ 16 | $this->config = require __DIR__ . '/../config/solana-sdk.php'; |
17 | } |
18 | |
19 | |
@@ -187,7 +187,7 @@
Legend
Covered by small (and larger) testsCovered by medium (and large) testsCovered by large tests (and tests of unknown size)Not coveredNot coverable
- Generated by php-code-coverage 10.1.14 using PHP 8.3.2 and PHPUnit 10.5.20 at Thu May 9 3:59:51 UTC 2024.
+ Generated by php-code-coverage 10.1.14 using PHP 8.3.2 and PHPUnit 10.5.20 at Thu May 9 9:22:33 UTC 2024.
diff --git a/build/html-coverage/Programs/DidSolProgram.php.html b/build/html-coverage/Programs/DidSolProgram.php.html
index 5c76311..16fd47e 100644
--- a/build/html-coverage/Programs/DidSolProgram.php.html
+++ b/build/html-coverage/Programs/DidSolProgram.php.html
@@ -361,7 +361,7 @@
Legend
Covered by small (and larger) testsCovered by medium (and large) testsCovered by large tests (and tests of unknown size)Not coveredNot coverable
- Generated by php-code-coverage 10.1.14 using PHP 8.3.2 and PHPUnit 10.5.20 at Thu May 9 3:59:51 UTC 2024.
+ Generated by php-code-coverage 10.1.14 using PHP 8.3.2 and PHPUnit 10.5.20 at Thu May 9 9:22:33 UTC 2024.
diff --git a/build/html-coverage/Programs/MetaplexProgram.php.html b/build/html-coverage/Programs/MetaplexProgram.php.html
index 8b5d564..4ef0dab 100644
--- a/build/html-coverage/Programs/MetaplexProgram.php.html
+++ b/build/html-coverage/Programs/MetaplexProgram.php.html
@@ -172,7 +172,7 @@
Legend
Covered by small (and larger) testsCovered by medium (and large) testsCovered by large tests (and tests of unknown size)Not coveredNot coverable
- Generated by php-code-coverage 10.1.14 using PHP 8.3.2 and PHPUnit 10.5.20 at Thu May 9 3:59:51 UTC 2024.
+ Generated by php-code-coverage 10.1.14 using PHP 8.3.2 and PHPUnit 10.5.20 at Thu May 9 9:22:33 UTC 2024.
diff --git a/build/html-coverage/Programs/SNS/Utils.php.html b/build/html-coverage/Programs/SNS/Utils.php.html
index ec9d9bc..5cf4700 100644
--- a/build/html-coverage/Programs/SNS/Utils.php.html
+++ b/build/html-coverage/Programs/SNS/Utils.php.html
@@ -46,22 +46,22 @@
Total |
-
- 66.67% covered (warning)
+
+ 73.77% covered (warning)
|
- 66.67% |
- 34 / 51 |
-
-
- 42.86% covered (danger)
+ 73.77% |
+ 45 / 61 |
+
+
+ 66.67% covered (warning)
|
- 42.86% |
- 3 / 7 |
- CRAP |
+ 66.67% |
+ 6 / 9 |
+ CRAP |
0.00% covered (danger)
@@ -75,22 +75,22 @@
Utils |
-
- 66.67% covered (warning)
+
+ 73.77% covered (warning)
|
- 66.67% |
- 34 / 51 |
-
-
- 42.86% covered (danger)
+ 73.77% |
+ 45 / 61 |
+
+
+ 66.67% covered (warning)
|
- 42.86% |
- 3 / 7 |
- 34.81 |
+ 66.67% |
+ 6 / 9 |
+ 32.55 |
0.00% covered (danger)
@@ -102,7 +102,7 @@
| |
- loadConstants |
+ loadConstants |
100.00% covered (success)
@@ -124,7 +124,7 @@
|
- getHashedNameSync |
+ getHashedNameSync |
100.00% covered (success)
@@ -146,29 +146,29 @@
|
- getNameAccountKeySync |
+ getNameAccountKeySync |
-
- 92.31% covered (success)
+
+ 100.00% covered (success)
|
- 92.31% |
- 12 / 13 |
-
-
- 0.00% covered (danger)
+ 100.00% |
+ 13 / 13 |
+
+
+ 100.00% covered (success)
|
- 0.00% |
- 0 / 1 |
- 3.00 |
- |
+ 100.00% |
+ 1 / 1 |
+ 3 |
+ |
|
- reverseLookup |
+ reverseLookup |
0.00% covered (danger)
@@ -190,7 +190,7 @@
|
- deserializeReverse |
+ deserializeReverse |
0.00% covered (danger)
@@ -212,7 +212,7 @@
|
- getDomainKeySync |
+ getDomainKeySync |
70.00% covered (warning)
@@ -234,7 +234,7 @@
|
- _deriveSync |
+ _deriveSync |
100.00% covered (success)
@@ -255,6 +255,50 @@
|
|
+
+ getReverseKeySync |
+
+
+ 100.00% covered (success)
+
+
+ |
+ 100.00% |
+ 9 / 9 |
+
+
+ 100.00% covered (success)
+
+
+ |
+ 100.00% |
+ 1 / 1 |
+ 2 |
+ |
+
+
+
+ getNameOwner |
+
+
+ 100.00% covered (success)
+
+
+ |
+ 100.00% |
+ 1 / 1 |
+
+
+ 100.00% covered (success)
+
+
+ |
+ 100.00% |
+ 1 / 1 |
+ 1 |
+ |
+
+
@@ -265,142 +309,177 @@
2 | |
3 | namespace Attestto\SolanaPhpSdk\Programs\SNS; |
4 | |
- 5 | use Attestto\SolanaPhpSdk\Accounts\NameRegistryStateAccount; |
- 6 | use Attestto\SolanaPhpSdk\Connection; |
- 7 | use Attestto\SolanaPhpSdk\Exceptions\InputValidationException; |
- 8 | use Attestto\SolanaPhpSdk\Exceptions\SNSError; |
- 9 | use Attestto\SolanaPhpSdk\PublicKey; |
- 10 | use Attestto\SolanaPhpSdk\Util\Buffer; |
- 11 | |
- 12 | trait Utils |
- 13 | { |
- 14 | |
- 15 | |
- 16 | public mixed $config; |
- 17 | public $centralStateSNSRecords; |
- 18 | |
+ 5 | use Attestto\SolanaPhpSdk\Exceptions\AccountNotFoundException; |
+ 6 | use Attestto\SolanaPhpSdk\Programs\SNS\State\NameRegistryStateAccount; |
+ 7 | use Attestto\SolanaPhpSdk\Connection; |
+ 8 | use Attestto\SolanaPhpSdk\Exceptions\InputValidationException; |
+ 9 | use Attestto\SolanaPhpSdk\Exceptions\SNSError; |
+ 10 | |
+ 11 | use Attestto\SolanaPhpSdk\PublicKey; |
+ 12 | use Attestto\SolanaPhpSdk\Util\Buffer; |
+ 13 | |
+ 14 | trait Utils |
+ 15 | { |
+ 16 | |
+ 17 | |
+ 18 | public mixed $config; |
19 | |
- 20 | |
+ 20 | |
21 | |
- 22 | private function loadConstants() |
- 23 | { |
- 24 | $jsonFilePath = dirname(__DIR__) . '/SNS/Constants/config.json'; |
- 25 | return json_decode(file_get_contents($jsonFilePath), true); |
- 26 | } |
- 27 | |
- 28 | public function getHashedNameSync(string $name): Buffer |
- 29 | { |
- 30 | $input = $this->config['HASH_PREFIX'] . $name; |
- 31 | $hashed = hash('sha256', Buffer::from($input), true); |
- 32 | return Buffer::from($hashed); |
- 33 | } |
- 34 | |
- 35 | |
- 36 | |
- 37 | |
- 38 | |
- 39 | |
- 40 | |
- 41 | |
- 42 | |
- 43 | public function getNameAccountKeySync( |
- 44 | Buffer $hashed_name, |
- 45 | PublicKey $nameClass = null, |
- 46 | PublicKey $nameParent = null |
- 47 | ): PublicKey { |
- 48 | $seeds = [$hashed_name]; |
- 49 | $programIdPublicKey = new PublicKey($this->config['NAME_PROGRAM_ID']); |
- 50 | if ($nameClass) { |
- 51 | $seeds[] = $nameClass->toBuffer(); |
- 52 | } else { |
- 53 | $seeds[] = Buffer::alloc(32); |
- 54 | } |
- 55 | if ($nameParent) { |
- 56 | $seeds[] = $nameParent->toBuffer(); |
- 57 | } else { |
- 58 | $seeds[] = Buffer::alloc(32); |
- 59 | } |
- 60 | [$nameAccountKey] = PublicKey::findProgramAddressSync( |
- 61 | $seeds, |
- 62 | $programIdPublicKey |
- 63 | ); |
- 64 | return $nameAccountKey; |
- 65 | } |
- 66 | |
- 67 | |
- 68 | |
- 69 | |
- 70 | |
- 71 | |
- 72 | |
- 73 | |
- 74 | public function reverseLookup(Connection $connection, PublicKey $nameAccount): string |
- 75 | { |
- 76 | $hashedReverseLookup = $this->getHashedNameSync($nameAccount->toBase58()); |
- 77 | $reverseLookupAccount = $this->getNameAccountKeySync($hashedReverseLookup, $this->config->REVERSE_LOOKUP_CLASS); |
- 78 | |
- 79 | $registry = NameRegistryStateAccount::retrieve($connection, $reverseLookupAccount); |
- 80 | if (!$registry['data']) { |
- 81 | throw new SNSError(SNSError::NoAccountData); |
- 82 | } |
- 83 | |
- 84 | return $this->deserializeReverse($registry['data']); |
- 85 | } |
- 86 | |
- 87 | public function deserializeReverse( |
- 88 | $data |
- 89 | ): ?string { |
- 90 | if (!$data) { |
- 91 | return null; |
- 92 | } |
- 93 | $nameLength = unpack('V', substr($data, 0, 4))[1]; |
- 94 | return substr($data, 4, $nameLength); |
- 95 | } |
- 96 | |
- 97 | |
- 98 | |
- 99 | |
- 100 | |
- 101 | |
- 102 | |
- 103 | |
- 104 | function getDomainKeySync(string $domain, ?string $record = null): array { |
- 105 | if (substr($domain, -4) === ".sol") { |
- 106 | $domain = substr($domain, 0, -4); |
- 107 | } |
- 108 | $recordClass = $record === 'V2' ? $this->centralStateSNSRecords : null; |
- 109 | $splitted = explode(".", $domain); |
- 110 | if (count($splitted) === 2) { |
- 111 | $prefix = $record ? $record : "\x00"; |
- 112 | $sub = $prefix . $splitted[0]; |
- 113 | $parentKey = $this->_deriveSync($splitted[1])['pubkey']; |
- 114 | $result = $this->_deriveSync($sub, $parentKey, $recordClass); |
- 115 | return array_merge($result, ['isSub' => true, 'parent' => $parentKey]); |
- 116 | } else if (count($splitted) === 3 && $record) { |
- 117 | |
- 118 | $parentKey = $this->_deriveSync($splitted[2])['pubkey']; |
- 119 | |
- 120 | $subKey = $this->_deriveSync("\0" . $splitted[1], new PublicKey($parentKey))['pubkey']; |
- 121 | |
- 122 | $recordPrefix = $record === 'V2' ? "\x02" : "\x01"; |
- 123 | $result = $this->_deriveSync($recordPrefix . $splitted[0], new PublicKey($subKey), new PublicKey($recordClass)); |
- 124 | return array_merge($result, ['isSub' => true, 'parent' => $parentKey, 'isSubRecord' => true]); |
- 125 | } else if (count($splitted) >= 3) { |
- 126 | throw new SNSError(SNSError::InvalidInput); |
- 127 | } |
- 128 | $result = $this->_deriveSync($domain, new PublicKey($this->config['ROOT_DOMAIN_ACCOUNT'])); |
- 129 | return array_merge($result, ['isSub' => false, 'parent' => null]); |
- 130 | } |
- 131 | |
- 132 | function _deriveSync(string $name, PublicKey $parent = null, PublicKey $classKey = null): array |
- 133 | { |
- 134 | |
- 135 | $hashedDomainName = $this->getHashedNameSync($name); |
- 136 | $pubkey = $this->getNameAccountKeySync($hashedDomainName, $classKey, $parent ?: new PublicKey($this->config['ROOT_DOMAIN_ACCOUNT'])); |
- 137 | return ['pubkey' => $pubkey, 'hashed' => $hashedDomainName]; |
- 138 | } |
- 139 | |
- 140 | } |
+ 22 | |
+ 23 | |
+ 24 | private function loadConstants() |
+ 25 | { |
+ 26 | $jsonFilePath = dirname(__DIR__) . '/SNS/Constants/config.json'; |
+ 27 | return json_decode(file_get_contents($jsonFilePath), true); |
+ 28 | } |
+ 29 | |
+ 30 | public function getHashedNameSync(string $name): Buffer |
+ 31 | { |
+ 32 | $input = $this->config['HASH_PREFIX'] . $name; |
+ 33 | $hashed = hash('sha256', Buffer::from($input), true); |
+ 34 | return Buffer::from($hashed); |
+ 35 | } |
+ 36 | |
+ 37 | |
+ 38 | |
+ 39 | |
+ 40 | |
+ 41 | |
+ 42 | |
+ 43 | |
+ 44 | |
+ 45 | public function getNameAccountKeySync( |
+ 46 | Buffer $hashed_name, |
+ 47 | PublicKey $nameClass = null, |
+ 48 | PublicKey $nameParent = null |
+ 49 | ): PublicKey { |
+ 50 | $seeds = [$hashed_name]; |
+ 51 | $programIdPublicKey = new PublicKey($this->config['NAME_PROGRAM_ID']); |
+ 52 | if ($nameClass) { |
+ 53 | $seeds[] = $nameClass->toBuffer(); |
+ 54 | } else { |
+ 55 | $seeds[] = Buffer::alloc(32); |
+ 56 | } |
+ 57 | if ($nameParent) { |
+ 58 | $seeds[] = $nameParent->toBuffer(); |
+ 59 | } else { |
+ 60 | $seeds[] = Buffer::alloc(32); |
+ 61 | } |
+ 62 | [$nameAccountKey] = PublicKey::findProgramAddressSync( |
+ 63 | $seeds, |
+ 64 | $programIdPublicKey |
+ 65 | ); |
+ 66 | return $nameAccountKey; |
+ 67 | } |
+ 68 | |
+ 69 | |
+ 70 | |
+ 71 | |
+ 72 | |
+ 73 | |
+ 74 | |
+ 75 | |
+ 76 | public function reverseLookup(Connection $connection, PublicKey $nameAccount): string |
+ 77 | { |
+ 78 | $hashedReverseLookup = $this->getHashedNameSync($nameAccount->toBase58()); |
+ 79 | $reverseLookupAccount = $this->getNameAccountKeySync($hashedReverseLookup, $this->config->REVERSE_LOOKUP_CLASS); |
+ 80 | |
+ 81 | $registry = NameRegistryStateAccount::retrieve($connection, $reverseLookupAccount); |
+ 82 | if (!$registry['data']) { |
+ 83 | throw new SNSError(SNSError::NoAccountData); |
+ 84 | } |
+ 85 | |
+ 86 | return $this->deserializeReverse($registry['data']); |
+ 87 | } |
+ 88 | |
+ 89 | public function deserializeReverse( |
+ 90 | $data |
+ 91 | ): ?string { |
+ 92 | if (!$data) { |
+ 93 | return null; |
+ 94 | } |
+ 95 | $nameLength = unpack('V', substr($data, 0, 4))[1]; |
+ 96 | return substr($data, 4, $nameLength); |
+ 97 | } |
+ 98 | |
+ 99 | |
+ 100 | |
+ 101 | |
+ 102 | |
+ 103 | |
+ 104 | |
+ 105 | |
+ 106 | function getDomainKeySync(string $domain, ?string $record = null): array { |
+ 107 | if (substr($domain, -4) === ".sol") { |
+ 108 | $domain = substr($domain, 0, -4); |
+ 109 | } |
+ 110 | $recordClass = $record === 'V2' ? $this->centralStateSNSRecords : null; |
+ 111 | $splitted = explode(".", $domain); |
+ 112 | if (count($splitted) === 2) { |
+ 113 | $prefix = $record ? $record : "\x00"; |
+ 114 | $sub = $prefix . $splitted[0]; |
+ 115 | $parentKey = $this->_deriveSync($splitted[1])['pubkey']; |
+ 116 | $result = $this->_deriveSync($sub, $parentKey, $recordClass); |
+ 117 | return array_merge($result, ['isSub' => true, 'parent' => $parentKey]); |
+ 118 | } else if (count($splitted) === 3 && $record) { |
+ 119 | |
+ 120 | $parentKey = $this->_deriveSync($splitted[2])['pubkey']; |
+ 121 | |
+ 122 | $subKey = $this->_deriveSync("\0" . $splitted[1], new PublicKey($parentKey))['pubkey']; |
+ 123 | |
+ 124 | $recordPrefix = $record === 'V2' ? "\x02" : "\x01"; |
+ 125 | $result = $this->_deriveSync($recordPrefix . $splitted[0], new PublicKey($subKey), new PublicKey($recordClass)); |
+ 126 | return array_merge($result, ['isSub' => true, 'parent' => $parentKey, 'isSubRecord' => true]); |
+ 127 | } else if (count($splitted) >= 3) { |
+ 128 | throw new SNSError(SNSError::InvalidInput); |
+ 129 | } |
+ 130 | $result = $this->_deriveSync($domain, new PublicKey($this->config['ROOT_DOMAIN_ACCOUNT'])); |
+ 131 | return array_merge($result, ['isSub' => false, 'parent' => null]); |
+ 132 | } |
+ 133 | |
+ 134 | function _deriveSync(string $name, PublicKey $parent = null, PublicKey $classKey = null): array |
+ 135 | { |
+ 136 | |
+ 137 | $hashedDomainName = $this->getHashedNameSync($name); |
+ 138 | $pubkey = $this->getNameAccountKeySync($hashedDomainName, $classKey, $parent ?: new PublicKey($this->config['ROOT_DOMAIN_ACCOUNT'])); |
+ 139 | return ['pubkey' => $pubkey, 'hashed' => $hashedDomainName]; |
+ 140 | } |
+ 141 | |
+ 142 | |
+ 143 | |
+ 144 | |
+ 145 | |
+ 146 | |
+ 147 | |
+ 148 | |
+ 149 | |
+ 150 | |
+ 151 | |
+ 152 | |
+ 153 | public function getReverseKeySync(string $domain, bool $isSub = null): PublicKey { |
+ 154 | $domainKeySync = $this->getDomainKeySync($domain); |
+ 155 | $pubkey = $domainKeySync['pubkey']; |
+ 156 | $parent = $domainKeySync['parent']; |
+ 157 | $hashedReverseLookup = $this->getHashedNameSync($pubkey->toBase58()); |
+ 158 | return $this->getNameAccountKeySync( |
+ 159 | $hashedReverseLookup, |
+ 160 | new PublicKey($this->config['REVERSE_LOOKUP_CLASS']), |
+ 161 | $isSub ? $parent : null |
+ 162 | ); |
+ 163 | } |
+ 164 | |
+ 165 | |
+ 166 | |
+ 167 | |
+ 168 | |
+ 169 | public function getNameOwner(Connection $connection, string $parentNameKey): array |
+ 170 | { |
+ 171 | return NameRegistryStateAccount::retrieve($connection, $parentNameKey); |
+ 172 | |
+ 173 | } |
+ 174 | |
+ 175 | } |
@@ -411,7 +490,7 @@
Legend
Covered by small (and larger) testsCovered by medium (and large) testsCovered by large tests (and tests of unknown size)Not coveredNot coverable
- Generated by php-code-coverage 10.1.14 using PHP 8.3.2 and PHPUnit 10.5.20 at Thu May 9 3:59:51 UTC 2024.
+ Generated by php-code-coverage 10.1.14 using PHP 8.3.2 and PHPUnit 10.5.20 at Thu May 9 9:22:33 UTC 2024.
diff --git a/build/html-coverage/Programs/SNS/dashboard.html b/build/html-coverage/Programs/SNS/dashboard.html
index 33cbd68..e928358 100644
--- a/build/html-coverage/Programs/SNS/dashboard.html
+++ b/build/html-coverage/Programs/SNS/dashboard.html
@@ -59,9 +59,8 @@ Insufficient Coverage
| |
- Attestto\SolanaPhpSdk\Programs\SNS\Bindings | 0% |
- Attestto\SolanaPhpSdk\Programs\SNS\Utils | 66% |
- Attestto\SolanaPhpSdk\Programs\SNS\Instructions\Instructions | 85% |
+ Attestto\SolanaPhpSdk\Programs\SNS\Bindings | 52% |
+ Attestto\SolanaPhpSdk\Programs\SNS\Utils | 73% |
@@ -78,9 +77,8 @@ Project Risks
|