Skip to content

Commit fe4e467

Browse files
committed
- add golos donate operation
1 parent 1dbc5ad commit fe4e467

File tree

3 files changed

+91
-1
lines changed

3 files changed

+91
-1
lines changed

Tools/ChainOperations/ChainOperations.php

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class ChainOperations
1414
const OPERATION_CUSTOM_JSON = 'custom_json';
1515
const OPERATION_CUSTOM = 'custom';//only for VIZ
1616
const OPERATION_WITNESS_UPDATE = 'witness_update';
17+
const OPERATION_DONATE = 'donate';
1718

1819
/** @var array */
1920
protected static $opMap = [];

Tools/ChainOperations/ChainOperationsGolos.php

+17-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class ChainOperationsGolos
1414
ChainOperations::OPERATION_TRANSFER => 2,
1515
ChainOperations::OPERATION_CUSTOM_JSON => 18,
1616
ChainOperations::OPERATION_WITNESS_UPDATE => 11,
17+
ChainOperations::OPERATION_DONATE => 54,
1718
];
1819

1920
const FIELDS_TYPES = [
@@ -53,7 +54,7 @@ class ChainOperationsGolos
5354
'id' => OperationSerializer::TYPE_STRING,
5455
'json' => OperationSerializer::TYPE_STRING
5556
],
56-
ChainOperations::OPERATION_WITNESS_UPDATE => [
57+
ChainOperations::OPERATION_WITNESS_UPDATE => [
5758
'owner' => OperationSerializer::TYPE_STRING,
5859
'url' => OperationSerializer::TYPE_STRING,
5960
'block_signing_key' => OperationSerializer::TYPE_PUBLIC_KEY,
@@ -64,6 +65,21 @@ class ChainOperationsGolos
6465
'account_creation_fee' => OperationSerializer::TYPE_ASSET,
6566
'maximum_block_size' => OperationSerializer::TYPE_INT32,
6667
'sbd_interest_rate' => OperationSerializer::TYPE_INT16
68+
],
69+
ChainOperations::OPERATION_DONATE => [
70+
'from' => OperationSerializer::TYPE_STRING,
71+
'to' => OperationSerializer::TYPE_STRING,
72+
'amount' => OperationSerializer::TYPE_ASSET,
73+
'memo' => OperationSerializer::TYPE_DONATE_MEMO,
74+
'extensions' => OperationSerializer::TYPE_SET_FUTURE_EXTENSIONS
75+
],
76+
OperationSerializer::TYPE_DONATE_MEMO => [
77+
'app' => OperationSerializer::TYPE_STRING,
78+
'version' => OperationSerializer::TYPE_INT16,
79+
'target' => OperationSerializer::TYPE_VARIANT_OBJECT,
80+
'comment' => OperationSerializer::TYPE_OPTIONAL_STRING
81+
],
82+
OperationSerializer::TYPE_FUTURE_EXTENSIONS => [
6783
]
6884
];
6985
}

examples/Broadcast/Donate.php

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
<?php
2+
3+
4+
namespace GrapheneNodeClient\examples\Broadcast;
5+
6+
use GrapheneNodeClient\Commands\CommandQueryData;
7+
use GrapheneNodeClient\Commands\Single\BroadcastTransactionSynchronousCommand;
8+
use GrapheneNodeClient\Connectors\Http\GolosHttpJsonRpcConnector;
9+
use GrapheneNodeClient\Connectors\Http\SteemitHttpJsonRpcConnector;
10+
use GrapheneNodeClient\Connectors\Http\VizHttpJsonRpcConnector;
11+
use GrapheneNodeClient\Connectors\Http\WhalesharesHttpJsonRpcConnector;
12+
use GrapheneNodeClient\Connectors\WebSocket\GolosWSConnector;
13+
use GrapheneNodeClient\Connectors\WebSocket\SteemitWSConnector;
14+
use GrapheneNodeClient\Connectors\WebSocket\VizWSConnector;
15+
use GrapheneNodeClient\Connectors\WebSocket\WhalesharesWSConnector;
16+
use GrapheneNodeClient\Tools\Transaction;
17+
18+
19+
ini_set('display_errors', 1);
20+
ini_set('display_startup_errors', 1);
21+
error_reporting(E_ALL);
22+
require __DIR__ . '/../../vendor/autoload.php';
23+
24+
echo "\n Donate.php START";
25+
26+
27+
$connector = new GolosWSConnector();
28+
//$connector = new SteemitWSConnector();
29+
//$connector = new VizWSConnector();
30+
//$connector = new WhalesharesWSConnector();
31+
//$connector = new GolosHttpJsonRpcConnector();
32+
//$connector = new SteemitHttpJsonRpcConnector();
33+
//$connector = new VizHttpJsonRpcConnector();
34+
//$connector = new WhalesharesHttpJsonRpcConnector();
35+
36+
37+
//transfer agregation to few users
38+
$chainName = $connector->getPlatform();
39+
/** @var CommandQueryData $tx */
40+
$tx = Transaction::init($connector);
41+
$tx->setParamByKey(
42+
'0:operations:0',
43+
[
44+
'donate',
45+
[
46+
'from' => 't3ran13',
47+
'to' => 'redhat',
48+
'amount' => '10.000 GOLOS',
49+
'memo' =>
50+
[
51+
'app' => 'golos-id',
52+
'version' => 1,
53+
'target' => [
54+
'author' => 'redhat',
55+
'permlink' => 'vozmeshenii-ubytkov-prichinennykh-nekachestvennoi-uslugoi'
56+
],
57+
'comment' => 'test php--graphene-node-client'
58+
],
59+
'extensions' => []
60+
]
61+
]
62+
);
63+
Transaction::sign($chainName, $tx, ['active' => '5_active_private_key']);
64+
65+
$command = new BroadcastTransactionSynchronousCommand($connector);
66+
$answer = $command->execute(
67+
$tx
68+
);
69+
70+
71+
72+
echo PHP_EOL . '<pre>' . print_r($answer, true) . '<pre>';
73+
die; //FIXME delete it

0 commit comments

Comments
 (0)