-
Notifications
You must be signed in to change notification settings - Fork 8
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 #21 from AElfProject/dev
Release v1.2.3
Showing
293 changed files
with
99,984 additions
and
43,277 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,2 @@ | ||
/vendor/ | ||
/.idea/ |
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 |
---|---|---|
@@ -1,2 +1,143 @@ | ||
# aelf-sdk.php | ||
AElf php SDK | ||
# AElf-sdk.php | ||
|
||
#Introduction | ||
|
||
This is a PHP client library, used to communicate with the [AElf](https://github.com/AElfProject/AElf) API. | ||
|
||
## Installation | ||
AElf php SDK | ||
|
||
In order to install this library via composer run the following command in the console: | ||
|
||
```lang=bash | ||
$ composer require aelf/aelf-sdk | ||
``` | ||
composer require curl/curl | ||
|
||
If you directly clone the sdk You must install composer and execute it in the root directory | ||
|
||
```lang=bash | ||
"aelf/aelf-sdk": "dev-dev" | ||
``` | ||
|
||
## Environment configuration And extensions that need to be turned on | ||
|
||
```lang=bash | ||
1. PHP => 7.0 | ||
2. gmp | ||
3. curl | ||
``` | ||
|
||
## Basic usage | ||
|
||
```php | ||
require_once 'vendor/autoload.php'; | ||
use AElf\AElf; | ||
$url = '127.0.0.1:8000'; | ||
$aelfClient = new AElf($url); | ||
$height = $aelfClient->GetBlockHeight(); | ||
``` | ||
### Examples | ||
|
||
You can also see full examples in `./example`; | ||
|
||
### Interface | ||
|
||
Interface methods can be easily available by the instance "aelfClient" shown in basic usage. The following is a list of input parameters and output for each method. Check out the [Web api reference](https://docs.aelf.io/v/dev/reference) for detailed Interface description. | ||
|
||
#### IBlockAppService | ||
|
||
```php | ||
public function getBlockHeight(); | ||
|
||
public function getBlockByHash($blockHash,$includeTransactions = false); | ||
|
||
public function getBlockByHeight($blockHeight,$includeTransactions = false); | ||
|
||
``` | ||
|
||
#### IChainAppService | ||
|
||
```php | ||
public function getChainStatus(); | ||
|
||
public function getContractFileDescriptorSet($address); | ||
|
||
public function getCurrentRoundInformationAsync(); | ||
|
||
public function getTaskQueueStatusAsync(); | ||
|
||
public function getChainIdAsync(); | ||
``` | ||
#### INetAppService | ||
|
||
```php | ||
public function addPeer($address); | ||
|
||
public function removePeer($address); | ||
|
||
public function getPeers($withMetrics); | ||
|
||
public function getNetworkInfo(); | ||
``` | ||
#### ITransactionAppService | ||
|
||
```php | ||
public function getTransactionPoolStatus(); | ||
|
||
public function executeTransaction($input); | ||
|
||
public function executeRawTransaction($input); | ||
|
||
public function createRawTransaction($input); | ||
|
||
public function sendRawTransaction($input); | ||
|
||
public function sendTransaction($input); | ||
|
||
public function sendTransactions($input); | ||
|
||
public function getTransactionResult($transactionId); | ||
|
||
public function getTransactionResults($blockHash, $offset = 0, $limit = 10); | ||
|
||
public function getMerklePathByTransactionId($transactionId); | ||
``` | ||
|
||
#### IClientService | ||
|
||
```php | ||
public function isConnected(); | ||
|
||
public function getFormattedAddress($privateKey, $address); | ||
|
||
public function getAddressFromPubKey($pubKey) ; | ||
|
||
public function getGenesisContractAddress(); | ||
|
||
public function getContractAddressByName($privateKey, $contractNameHash); | ||
``` | ||
### Test | ||
|
||
This module contains tests for all services provided by AElf. You can see how to properly use services provided by AElf here. | ||
|
||
You need to firstly set necessary parameters to make sure tests can run successfully. | ||
|
||
1. Set baseUrl to your target url. | ||
|
||
|
||
```php | ||
|
||
$url = "Http://127.0.0.1:8001"; | ||
``` | ||
|
||
|
||
2. Give a valid privateKey of a node. | ||
|
||
```php | ||
$this->privateKey = 'be3abe5c1439899ac2efd0001e15715fd989a3ae11f09e1cb95d320cd4993e2a'; | ||
``` | ||
|
||
### Note | ||
|
||
You need to run a local or remote AElf node to run the unit test successfully. If you're not familiar with how to run a node or multiple nodes, please see [Running a node](https://docs.AElf.io/v/dev/main/main/run-node) / [Running multiple nodes](https://docs.AElf.io/v/dev/main/main/multi-nodes) for more information. |
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,87 @@ | ||
jobs: | ||
# All tasks on window | ||
- job: build_all_window | ||
pool: | ||
vmImage: 'windows-2019' | ||
variables: | ||
phpVersion: 8.2 | ||
steps: | ||
- task: UseDotNet@2 | ||
inputs: | ||
version: '6.0.x' | ||
- script: | | ||
cp scripts/aelf-node/php.ini /c/tools/php/php.ini | ||
php -c /c/tools/php/php.ini | ||
- script: | | ||
php -r "copy('https://install.phpcomposer.com/installer', 'composer-setup.php');" | ||
php composer-setup.php | ||
php composer.phar config -g repo.packagist composer https://packagist.phpcomposer.com | ||
php composer.phar install --no-interaction --prefer-dist --ignore-platform-reqs | ||
displayName: 'composer install' | ||
- powershell: ./scripts/aelf-node/start-window.ps1 | ||
displayName: 'deploy and test' | ||
# All tasks on Linux | ||
- job: build_all_linux | ||
displayName: Build all tasks (Linux) | ||
services: | ||
redis: | ||
image: redis | ||
ports: | ||
- 6379:6379 | ||
pool: | ||
vmImage: ubuntu-latest | ||
variables: | ||
phpVersion: 8.2 | ||
steps: | ||
- task: UseDotNet@2 | ||
inputs: | ||
version: '6.0.x' | ||
- script: cd scripts/aelf-node && bash start.sh | ||
displayName: 'Deploy a full node' | ||
- script: | | ||
sudo update-alternatives --set php /usr/bin/php$(phpVersion) | ||
sudo update-alternatives --set phar /usr/bin/phar$(phpVersion) | ||
sudo update-alternatives --set phpdbg /usr/bin/phpdbg$(phpVersion) | ||
sudo update-alternatives --set php-cgi /usr/bin/php-cgi$(phpVersion) | ||
sudo update-alternatives --set phar.phar /usr/bin/phar.phar$(phpVersion) | ||
php -version | ||
displayName: 'Use PHP version $(phpVersion)' | ||
- script: | | ||
php -r "copy('https://install.phpcomposer.com/installer', 'composer-setup.php');" | ||
php composer-setup.php | ||
sudo mv composer.phar /usr/local/bin/composer | ||
composer config -g repo.packagist composer https://packagist.phpcomposer.com | ||
composer install --no-interaction --prefer-dist --ignore-platform-reqs | ||
displayName: 'composer install' | ||
- script: php phpunit.phar --bootstrap bootstrap.php tests/AElfTest.php | ||
displayName: 'test' | ||
- job: build_all_macos | ||
# All tasks on macOS | ||
displayName: Build all tasks (macos) | ||
pool: | ||
vmImage: macOS-latest | ||
variables: | ||
phpVersion: 8.2 | ||
steps: | ||
- task: UseDotNet@2 | ||
inputs: | ||
version: '6.0.x' | ||
- script: cd scripts/aelf-node && bash start-mac.sh | ||
displayName: 'Deploy a full node' | ||
- script: | | ||
sudo update-alternatives --set php /usr/bin/php$(phpVersion) | ||
sudo update-alternatives --set phar /usr/bin/phar$(phpVersion) | ||
sudo update-alternatives --set phpdbg /usr/bin/phpdbg$(phpVersion) | ||
sudo update-alternatives --set php-cgi /usr/bin/php-cgi$(phpVersion) | ||
sudo update-alternatives --set phar.phar /usr/bin/phar.phar$(phpVersion) | ||
php -version | ||
displayName: 'Use PHP version $(phpVersion)' | ||
- script: | | ||
php -r "copy('https://install.phpcomposer.com/installer', 'composer-setup.php');" | ||
php composer-setup.php | ||
sudo mv composer.phar /usr/local/bin/composer | ||
composer config -g repo.packagist composer https://packagist.phpcomposer.com | ||
composer install --no-interaction --prefer-dist --ignore-platform-reqs | ||
- script: php phpunit.phar --bootstrap bootstrap.php tests/AElfTest.php | ||
displayName: 'test' | ||
|
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,2 @@ | ||
<?php | ||
require __DIR__ . '/vendor/autoload.php'; |
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 |
---|---|---|
@@ -1,43 +1,43 @@ | ||
{ | ||
"name": "aelf/aelf-sdk", | ||
"type": "library", | ||
"description": "AElf php SDK", | ||
"keywords": ["aelf-sdk","aelf","AElf php SDK"], | ||
"license": "MIT", | ||
"authors": [ | ||
|
||
], | ||
"homepage": "https://github.com/AElfProject/aelf-sdk.php", | ||
"require": { | ||
"php": ">=5.6", | ||
"ext-gmp": "*", | ||
"ext-curl": "*", | ||
"kornrunner/secp256k1": "^0.1.2" | ||
}, | ||
"require-dev": { | ||
"phpunit/phpunit": "^6.2" | ||
}, | ||
"autoload": { | ||
"classmap": [ | ||
"src/helper" | ||
], | ||
"files":["src/helper/Sha.php"], | ||
"psr-4": { | ||
"Aelf\\": "src/", | ||
"Aelf\\Api\\":"src/sdk/", | ||
"Hhxsv5\\PhpMultiCurl\\": "src/helper", | ||
"StephenHill\\": "src/helper", | ||
"StephenHill\\Benchmarks\\": "benchmarks/", | ||
"Aelf\\AelfECDSA\\": "src/helper/", | ||
"Google\\Protobuf\\": "src/pro/Google/Protobuf", | ||
"GPBMetadata\\Google\\Protobuf\\": "src/GPBMetadata/Google/Protobuf", | ||
"Aelf\\Protobuf\\Generated\\": "src/pro/Aelf/Protobuf/Generated/", | ||
"GPBMetadata\\": "src/pro/GPBMetadata/" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"Aelf\\example\\": "example/" | ||
} | ||
} | ||
} | ||
{ | ||
"name": "aelf/aelf-sdk", | ||
"type": "library", | ||
"description": "AElf php SDK", | ||
"keywords": ["aelf-sdk","aelf","AElf php SDK"], | ||
"license": "MIT", | ||
"authors": [ | ||
|
||
], | ||
"homepage": "https://github.com/AElfProject/aelf-sdk.php", | ||
"require": { | ||
"php": ">=5.6", | ||
"ext-gmp": "*", | ||
"ext-curl": "*", | ||
"kornrunner/secp256k1": "^0.1.2", | ||
"hhxsv5/php-multi-curl": "~1.0", | ||
"stephenhill/base58": "^1.1", | ||
"bitcoin-php/bitcoin-ecdsa" : "^1.3", | ||
"google/protobuf": "^3.11", | ||
"tuupola/base58": "^2.0" | ||
}, | ||
"require-dev": { | ||
"phpunit/phpunit": "^10" | ||
}, | ||
"autoload": { | ||
"classmap": [ | ||
"src/helper" | ||
], | ||
"files":["src/helper/Sha.php","src/helper/CurlUniversalRequest.php"], | ||
"psr-4": { | ||
"AElf\\": "src/", | ||
"AElf\\Api\\":"src/sdk/", | ||
"Google\\Protobuf\\": "src/protobuf/Google/Protobuf", | ||
"AElf\\Protobuf\\Generated\\": "src/protobuf/AElf/Protobuf/Generated/", | ||
"GPBMetadata\\":"src/protobuf/GPBMetadata" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"AElf\\example\\": "example/" | ||
} | ||
} | ||
} |
Oops, something went wrong.