-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from Attestto-com/feature/spl-token
Feature/spl token
- Loading branch information
Showing
26 changed files
with
713 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<component name="ProjectRunConfigurationManager"> | ||
<configuration default="false" name="tests" type="PHPUnitRunConfigurationType" factoryName="PHPUnit" editBeforeRun="true"> | ||
<TestRunner configuration_file="$PROJECT_DIR$/phpunit.xml" directory="$PROJECT_DIR$/tests" use_alternative_configuration_file="true" /> | ||
<method v="2" /> | ||
</configuration> | ||
</component> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
|
||
return [ | ||
|
||
'TOKEN_PROGRAM_ID' => env('TOKEN_PROGRAM_ID') ?? 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA', | ||
//------- | ||
'devnet' => [ | ||
'mints' => [ | ||
'usdc' => env('USDC_MINT_DEVNET'), | ||
'helium' => env('MAINNET_HELIUM_MINT'), | ||
'solana' => env('MAINNET_SOLANA_MINT'), | ||
], | ||
'network' => [ | ||
'type' => env('NETWORK'), | ||
'attesto_rpc' => env('ATTESTO_RPC'), | ||
'fallback_rpc_1' => env('FALLBACK_RPC_1'), | ||
'fallback_rpc_2' => env('FALLBACK_RPC_2'), | ||
], | ||
'api_keys' => [ | ||
'helius' => env('HELIUS_API_KEY'), | ||
], | ||
'data_source' => env('DATA_SOURCE'), | ||
'keys' => [ | ||
'dapp_pk' => env('DAPP_PK'), // Signer | ||
'burn_address' => env('SOLANA_BURN_ADDRESS'), // Not in use | ||
'treasury_pk' => env('TREASURY_PK'), // Not in use | ||
'fees_pk' => env('FEES_PK'), // Fee Taker | ||
], | ||
], | ||
'network' => [ | ||
'type' => env('NETWORK'), | ||
'attesto_rpc' => env('ATTESTO_RPC'), | ||
'fallback_rpc_1' => env('FALLBACK_RPC_1'), | ||
'fallback_rpc_2' => env('FALLBACK_RPC_2'), | ||
], | ||
'api_keys' => [ | ||
'helius' => env('HELIUS_API_KEY'), | ||
], | ||
'data_source' => env('DATA_SOURCE'), | ||
'keys' => [ | ||
'dapp_pk' => env('DAPP_PK'), // Signer | ||
'burn_address' => env('SOLANA_BURN_ADDRESS'), // Not in use | ||
'treasury_pk' => env('TREASURY_PK'), // Not in use | ||
'fees_pk' => env('FEES_PK'), // Fee Taker | ||
], | ||
'fees' => [ | ||
'key_registration' => env('KEY_REGISTRATION_FEE'), | ||
'did_registration' => env('DID_REGISTRATION_FEE'), | ||
'did_update' => env('DID_UPDATE_FEE'), | ||
'vc_issuing' => env('VC_ISSUING_FEE'), | ||
'vc_proofing' => env('VC_PROOFING_FEE'), | ||
'vc_verifying' => env('VC_VERIFYING_FEE'), | ||
'vc_revoking' => env('VC_REVOKING_FEE'), | ||
], | ||
'subscription_prices' => [ | ||
'monthly' => env('KEY_REGISTRATION_FEE', 0.01), | ||
'anual' => env('DID_REGISTRATION_FEE', 0.1), | ||
], | ||
|
||
]; |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Connection Class | ||
|
||
The `Connection` class is part of the `Attestto\SolanaPhpSdk` namespace and extends the `Program` class. It provides methods to interact with the Solana network. | ||
|
||
## Methods | ||
|
||
### `getAccountInfo(string $pubKey): array` | ||
|
||
This method retrieves the account information for a given public key. It throws an `AccountNotFoundException` if the account is not found. | ||
|
||
### `getBalance(string $pubKey): float` | ||
|
||
This method retrieves the balance for a given public key. | ||
|
||
### `getConfirmedTransaction(string $transactionSignature): array|null` | ||
|
||
This method retrieves a confirmed transaction using the transaction signature. | ||
|
||
### `getTransaction(string $transactionSignature): array|null` | ||
|
||
This method retrieves a transaction using the transaction signature. This method is only available in solana-core v1.7 or newer. | ||
|
||
### `getLatestBlockhash(?Commitment $commitment): array` | ||
|
||
This method retrieves the latest blockhash. | ||
|
||
### `sendTransaction(Transaction $transaction, array $signers, array $params = []): array|Response` | ||
|
||
This method sends a transaction. It signs the transaction with the provided signers and serializes it to a binary string. | ||
|
||
### `simulateTransaction(Transaction $transaction, array $signers, array $params = []): array|Response` | ||
|
||
This method simulates a transaction. It signs the transaction with the provided signers and serializes it to a binary string. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php | ||
|
||
namespace SplToken; | ||
|
||
use Attestto\SolanaPhpSdk\Programs\SplTokenProgram; | ||
use Attestto\SolanaPhpSdk\Tests\TestCase; | ||
|
||
class SPLTokenTest extends TestCase | ||
{ | ||
private $splTokenProgram; | ||
|
||
public function setUp(): void | ||
{ | ||
$client = $this->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 | ||
// ); | ||
// } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
namespace Attestto\SolanaPhpSdk\Exceptions; | ||
|
||
use Exception; | ||
class TokenAccountNotFoundError extends Exception | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
namespace Attestto\SolanaPhpSdk\Exceptions; | ||
|
||
use Exception; | ||
class TokenInvalidAccountOwnerError extends Exception | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
namespace Attestto\SolanaPhpSdk\Exceptions; | ||
|
||
use Exception; | ||
|
||
class TokenInvalidMintError extends Exception | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
namespace Attestto\SolanaPhpSdk\Exceptions; | ||
|
||
use Exception; | ||
class TokenOwnerOffCurveError extends Exception | ||
{ | ||
|
||
} |
Oops, something went wrong.