Skip to content

Commit

Permalink
- add golos donate operation
Browse files Browse the repository at this point in the history
  • Loading branch information
t3ran13 committed Oct 29, 2020
1 parent 1dbc5ad commit fe4e467
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 1 deletion.
1 change: 1 addition & 0 deletions Tools/ChainOperations/ChainOperations.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class ChainOperations
const OPERATION_CUSTOM_JSON = 'custom_json';
const OPERATION_CUSTOM = 'custom';//only for VIZ
const OPERATION_WITNESS_UPDATE = 'witness_update';
const OPERATION_DONATE = 'donate';

/** @var array */
protected static $opMap = [];
Expand Down
18 changes: 17 additions & 1 deletion Tools/ChainOperations/ChainOperationsGolos.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class ChainOperationsGolos
ChainOperations::OPERATION_TRANSFER => 2,
ChainOperations::OPERATION_CUSTOM_JSON => 18,
ChainOperations::OPERATION_WITNESS_UPDATE => 11,
ChainOperations::OPERATION_DONATE => 54,
];

const FIELDS_TYPES = [
Expand Down Expand Up @@ -53,7 +54,7 @@ class ChainOperationsGolos
'id' => OperationSerializer::TYPE_STRING,
'json' => OperationSerializer::TYPE_STRING
],
ChainOperations::OPERATION_WITNESS_UPDATE => [
ChainOperations::OPERATION_WITNESS_UPDATE => [
'owner' => OperationSerializer::TYPE_STRING,
'url' => OperationSerializer::TYPE_STRING,
'block_signing_key' => OperationSerializer::TYPE_PUBLIC_KEY,
Expand All @@ -64,6 +65,21 @@ class ChainOperationsGolos
'account_creation_fee' => OperationSerializer::TYPE_ASSET,
'maximum_block_size' => OperationSerializer::TYPE_INT32,
'sbd_interest_rate' => OperationSerializer::TYPE_INT16
],
ChainOperations::OPERATION_DONATE => [
'from' => OperationSerializer::TYPE_STRING,
'to' => OperationSerializer::TYPE_STRING,
'amount' => OperationSerializer::TYPE_ASSET,
'memo' => OperationSerializer::TYPE_DONATE_MEMO,
'extensions' => OperationSerializer::TYPE_SET_FUTURE_EXTENSIONS
],
OperationSerializer::TYPE_DONATE_MEMO => [
'app' => OperationSerializer::TYPE_STRING,
'version' => OperationSerializer::TYPE_INT16,
'target' => OperationSerializer::TYPE_VARIANT_OBJECT,
'comment' => OperationSerializer::TYPE_OPTIONAL_STRING
],
OperationSerializer::TYPE_FUTURE_EXTENSIONS => [
]
];
}
73 changes: 73 additions & 0 deletions examples/Broadcast/Donate.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?php


namespace GrapheneNodeClient\examples\Broadcast;

use GrapheneNodeClient\Commands\CommandQueryData;
use GrapheneNodeClient\Commands\Single\BroadcastTransactionSynchronousCommand;
use GrapheneNodeClient\Connectors\Http\GolosHttpJsonRpcConnector;
use GrapheneNodeClient\Connectors\Http\SteemitHttpJsonRpcConnector;
use GrapheneNodeClient\Connectors\Http\VizHttpJsonRpcConnector;
use GrapheneNodeClient\Connectors\Http\WhalesharesHttpJsonRpcConnector;
use GrapheneNodeClient\Connectors\WebSocket\GolosWSConnector;
use GrapheneNodeClient\Connectors\WebSocket\SteemitWSConnector;
use GrapheneNodeClient\Connectors\WebSocket\VizWSConnector;
use GrapheneNodeClient\Connectors\WebSocket\WhalesharesWSConnector;
use GrapheneNodeClient\Tools\Transaction;


ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
require __DIR__ . '/../../vendor/autoload.php';

echo "\n Donate.php START";


$connector = new GolosWSConnector();
//$connector = new SteemitWSConnector();
//$connector = new VizWSConnector();
//$connector = new WhalesharesWSConnector();
//$connector = new GolosHttpJsonRpcConnector();
//$connector = new SteemitHttpJsonRpcConnector();
//$connector = new VizHttpJsonRpcConnector();
//$connector = new WhalesharesHttpJsonRpcConnector();


//transfer agregation to few users
$chainName = $connector->getPlatform();
/** @var CommandQueryData $tx */
$tx = Transaction::init($connector);
$tx->setParamByKey(
'0:operations:0',
[
'donate',
[
'from' => 't3ran13',
'to' => 'redhat',
'amount' => '10.000 GOLOS',
'memo' =>
[
'app' => 'golos-id',
'version' => 1,
'target' => [
'author' => 'redhat',
'permlink' => 'vozmeshenii-ubytkov-prichinennykh-nekachestvennoi-uslugoi'
],
'comment' => 'test php--graphene-node-client'
],
'extensions' => []
]
]
);
Transaction::sign($chainName, $tx, ['active' => '5_active_private_key']);

$command = new BroadcastTransactionSynchronousCommand($connector);
$answer = $command->execute(
$tx
);



echo PHP_EOL . '<pre>' . print_r($answer, true) . '<pre>';
die; //FIXME delete it

0 comments on commit fe4e467

Please sign in to comment.