From fe4e4679ebcb5d90b56589c7bcffcffe47b5d2dc Mon Sep 17 00:00:00 2001 From: t3ran13 Date: Thu, 29 Oct 2020 19:38:27 +0300 Subject: [PATCH] - add golos donate operation --- Tools/ChainOperations/ChainOperations.php | 1 + .../ChainOperations/ChainOperationsGolos.php | 18 ++++- examples/Broadcast/Donate.php | 73 +++++++++++++++++++ 3 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 examples/Broadcast/Donate.php diff --git a/Tools/ChainOperations/ChainOperations.php b/Tools/ChainOperations/ChainOperations.php index 5c278e0..27f1d13 100644 --- a/Tools/ChainOperations/ChainOperations.php +++ b/Tools/ChainOperations/ChainOperations.php @@ -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 = []; diff --git a/Tools/ChainOperations/ChainOperationsGolos.php b/Tools/ChainOperations/ChainOperationsGolos.php index 32b5d06..f61e58d 100644 --- a/Tools/ChainOperations/ChainOperationsGolos.php +++ b/Tools/ChainOperations/ChainOperationsGolos.php @@ -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 = [ @@ -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, @@ -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 => [ ] ]; } \ No newline at end of file diff --git a/examples/Broadcast/Donate.php b/examples/Broadcast/Donate.php new file mode 100644 index 0000000..888b004 --- /dev/null +++ b/examples/Broadcast/Donate.php @@ -0,0 +1,73 @@ +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 . '
' . print_r($answer, true) . '
';
+die; //FIXME delete it