Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@
],
"homepage": "https://github.com/AElfProject/aelf-sdk.php",
"require": {
"php": ">=5.6",
"php": ">=7.1",
"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",
"google/protobuf": "^3.24",
"tuupola/base58": "^2.0"
},
"require-dev": {
"phpunit/phpunit": "^10"
"phpunit/phpunit": "^10.0"
},
"autoload": {
"classmap": [
Expand Down
207 changes: 109 additions & 98 deletions composer.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion scripts/aelf-node/start-mac.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ brew services start redis
brew install unzip
mkdir -p ~/.local/share/aelf/keys
cd ../../
wget https://github.com/AElfProject/AElf/releases/download/v1.2.3/aelf.zip && unzip aelf.zip
wget https://github.com/AElfProject/AElf/releases/download/v1.6.0/aelf.zip && unzip aelf.zip
cp scripts/aelf-node/keys/SD6BXDrKT2syNd1WehtPyRo3dPBiXqfGUj8UJym7YP9W9RynM.json ~/.local/share/aelf/keys/
cp scripts/aelf-node/app* aelf/
echo "start node"
Expand Down
2 changes: 1 addition & 1 deletion scripts/aelf-node/start-window.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ $job1 = Start-Job -ScriptBlock { cd D:\a\1\s\redis; .\redis-server.exe; }
sleep 30
mkdir -p C:\Users\VssAdministrator\AppData\Local\aelf\keys
cp -r scripts\aelf-node\keys\* C:\Users\VssAdministrator\AppData\Local\aelf\keys;
wget https://github.com/AElfProject/AElf/releases/download/v1.2.3/aelf.zip -OutFile aelf.zip ;
wget https://github.com/AElfProject/AElf/releases/download/v1.6.0/aelf.zip -OutFile aelf.zip ;
Expand-Archive -Path aelf.zip -DestinationPath aelf ;
cp scripts\aelf-node\appsettings.json aelf\aelf\appsettings.json ;
cp scripts\aelf-node\appsettings.MainChain.TestNet.json aelf\aelf\appsettings.MainChain.TestNet.json ;
Expand Down
2 changes: 1 addition & 1 deletion scripts/aelf-node/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ ip=`ip a | grep eth0 |grep 'inet' | awk -F/ '{print $1}'| awk '{print $2}'`
sudo apt update && apt install unzip
sudo mkdir -p /home/ubuntu/.ssh/aelf/keys && sudo mkdir -p /root/.ssh/aelf/keys
cd ../../
wget https://github.com/AElfProject/AElf/releases/download/v1.2.3/aelf.zip
wget https://github.com/AElfProject/AElf/releases/download/v1.6.0/aelf.zip
sudo unzip aelf.zip
sed -i "s/127.0.0.1/$ip/g" scripts/aelf-node/appsettings.json
sudo mkdir -p /root/.local/share/aelf/keys/
Expand Down
115 changes: 111 additions & 4 deletions src/AElf.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

use AElf\Api\NetSdk;
use AElf\Bytes\Bytes;
use AElf\Protobuf\Generated\CrossChainReceived;
use AElf\Protobuf\Generated\CrossChainTransferred;
use AElf\Protobuf\Generated\Transferred;
use GPBMetadata\Types;
use StephenHill\Base58;
use kornrunner\Secp256k1;
Expand Down Expand Up @@ -434,20 +437,20 @@ public function getTransactionFees($transactionResult)
if ($log['Name'] == 'TransactionFeeCharged') {
$transactionFee = new TransactionFeeCharged();
$transactionFee->mergeFromString(base64_decode($log['NonIndexed']));
array_push($transactionFees, [
$transactionFees[] = [
'name' => 'transaction_fee_charged',
'symbol' => $transactionFee->getSymbol(),
'amount' => $transactionFee->getAmount(),
]);
];
}
if ($log['Name'] == 'ResourceTokenCharged') {
$resourceTokenFee = new ResourceTokenCharged();
$resourceTokenFee->mergeFromString(base64_decode($log['NonIndexed']));
array_push($transactionFees, [
$transactionFees[] = [
'name' => 'resource_token_charged',
'symbol' => $resourceTokenFee->getSymbol(),
'amount' => $resourceTokenFee->getAmount(),
]);
];
}
}
}
Expand All @@ -463,4 +466,108 @@ public function calculateTransactionFee($input)
{
return $this->getBlockChainSdkObj()->calculateTransactionFee($input);
}


/**
* @param $privateKey
* @param $transactionId
* @return array
*/
public function getTransferred($privateKey, $transactionId): array
{
$items = [];
$response = $this->getTransactionResult($transactionId);
if (empty($response) || empty($response['Logs'])) return $items;
$contractNames = new Hash();
$contractNames->setValue(hex2bin(sha256('AElf.ContractNames.Token')));
$toAddress = $this->getContractAddressByName($privateKey, $contractNames);
foreach ($response['Logs'] as $log) {
if ($log['Name'] == 'Transferred' && $log['Address'] == $toAddress) {
$transferred = new Transferred();
$transferred->mergeFromString(base64_decode($log['NonIndexed']));

$tmpTransferred = new Transferred();
$tmpTransferred->mergeFromString(base64_decode($log['Indexed'][0]));
$transferred->setFrom($tmpTransferred->getFrom());

$tmpTransferred1 = new Transferred();
$tmpTransferred1->mergeFromString(base64_decode($log['Indexed'][1]));
$transferred->setTo($tmpTransferred1->getTo());

$tmpTransferred2 = new Transferred();

$tmpTransferred2->mergeFromString(base64_decode($log['Indexed'][2]));
$transferred->setSymbol($tmpTransferred2->getSymbol());
$items[] = [
'from' => encodeChecked($transferred->getFrom()->getValue()),
'to' => encodeChecked($transferred->getTo()->getValue()),
'symbol' => $transferred->getSymbol(),
'amount' => $transferred->getAmount(),
'memo' => $transferred->getMemo()
];
}
}
return $items;
}


public function getCrossChainTransferred($privateKey, $transactionId): array
{
$items = [];
$response = $this->getTransactionResult($transactionId);
if (empty($response) || empty($response['Logs'])) return $items;

$contractNames = new Hash();
$contractNames->setValue(hex2bin(sha256('AElf.ContractNames.Token')));
$toAddress = $this->getContractAddressByName($privateKey, $contractNames);

foreach ($response['Logs'] as $log) {
if ($log['Name'] == 'CrossChainTransferred' && $log['Address'] == $toAddress) {
$transferred = new CrossChainTransferred();
$transferred -> mergeFromString(base64_decode($log['NonIndexed']));
$items = [
'from' => encodeChecked($transferred->getFrom()->getValue()),
'to' => encodeChecked($transferred->getTo()->getValue()),
'symbol'=> $transferred->getSymbol(),
'amount'=> $transferred->getAmount(),
'memo'=> $transferred->getMemo(),
'issueChainId'=> $transferred->getIssueChainId(),
'toChainId'=> $transferred->getToChainId()
];
}
}
return $items;
}

public function getCrossChainReceived($privateKey, $transactionId): array
{
$items = [];
$response = $this->getTransactionResult($transactionId);
if (empty($response) || empty($response['Logs'])) return $items;

$contractNames = new Hash();
$contractNames->setValue(hex2bin(sha256('AElf.ContractNames.Token')));
$toAddress = $this->getContractAddressByName($privateKey, $contractNames);

foreach ($response['Logs'] as $log) {
if ($log['Name'] == 'CrossChainReceived' && $log['Address'] == $toAddress) {
$transferred = new CrossChainReceived();
$transferred -> mergeFromString(base64_decode($log['NonIndexed']));
$items = [
'from' => encodeChecked($transferred->getFrom()->getValue()),
'to' => encodeChecked($transferred->getTo()->getValue()),
'symbol'=> $transferred->getSymbol(),
'amount'=> $transferred->getAmount(),
'memo'=> $transferred->getMemo(),
'issueChainId'=> $transferred->getIssueChainId(),
'fromChainId'=> $transferred->getFromChainId(),
'parentChainHeight'=> $transferred->getParentChainHeight(),
'transferTransactionId'=> $transferred->getTransferTransactionId()
];
}
}
return $items;
}


}
16 changes: 8 additions & 8 deletions src/protobuf/AElf/Protobuf/Generated/CandidateVote.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 11 additions & 1 deletion src/protobuf/AElf/Protobuf/Generated/ContractUpdateInput.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading