mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
try to get all JsonRequestHandlerController Tests running with success, add page for creating raw transactions
This commit is contained in:
parent
21310f877e
commit
d6ae92fc72
@ -340,12 +340,13 @@ class JsonRequestHandlerController extends AppController {
|
||||
return;
|
||||
}
|
||||
$transaction_body = $transaction->getTransactionBody();
|
||||
$transaction_type_name = $transaction_body->getTransactionTypeName();
|
||||
$senderUser = null;
|
||||
if($transaction_type_name === 'transfer') {
|
||||
$senderUser = $transaction_body->getSpecificTransaction()->getSenderUser();
|
||||
} else if($transaction_type_name === 'creation') {
|
||||
$senderUser = $transaction->getFirstSigningUser();
|
||||
$senderUser = $transaction->getFirstSigningUser();
|
||||
if($transaction_body != null) {
|
||||
$transaction_type_name = $transaction_body->getTransactionTypeName();
|
||||
|
||||
if($transaction_type_name === 'transfer') {
|
||||
$senderUser = $transaction_body->getSpecificTransaction()->getSenderUser();
|
||||
}
|
||||
}
|
||||
// send notification email
|
||||
$noReplyEmail = Configure::read('noReplyEmail');
|
||||
@ -373,6 +374,15 @@ class JsonRequestHandlerController extends AppController {
|
||||
|
||||
private function putTransaction($transactionBase64) {
|
||||
$transaction = new Transaction($transactionBase64);
|
||||
//echo "new transaction\n$transactionBase64\n";
|
||||
/*try {
|
||||
$transactionBin = sodium_base642bin($transactionBase64, SODIUM_BASE64_VARIANT_URLSAFE_NO_PADDING);
|
||||
$transaction = new Transaction($transactionBin);
|
||||
} catch(\SodiumException $e) {
|
||||
//echo 'exception: '. $e->getMessage();
|
||||
return $this->returnJson(['state' => 'error', 'msg' => 'error decoding base 64', 'details' => $e->getMessage(), 'base64' => $transactionBase64]);
|
||||
}*/
|
||||
|
||||
//echo "after new transaction<br>";
|
||||
if($transaction->hasErrors()) {
|
||||
$this->sendEMailTransactionFailed($transaction, 'parse');
|
||||
|
||||
@ -7,6 +7,7 @@ use Model\Transactions\Transaction;
|
||||
use Model\Transactions\TransactionBody;
|
||||
|
||||
use Cake\Core\Configure;
|
||||
use Cake\I18n\Time;
|
||||
use Cake\ORM\TableRegistry;
|
||||
|
||||
/**
|
||||
@ -24,7 +25,7 @@ class TransactionsController extends AppController
|
||||
parent::initialize();
|
||||
$this->loadComponent('GradidoNumber');
|
||||
$this->loadComponent('JsonRpcRequestClient');
|
||||
$this->Auth->allow(['decode']);
|
||||
$this->Auth->allow(['decode', 'manualTransaction']);
|
||||
|
||||
}
|
||||
/**
|
||||
@ -170,6 +171,78 @@ class TransactionsController extends AppController
|
||||
$this->set('transaction', $transaction);
|
||||
}
|
||||
|
||||
public function manualTransaction()
|
||||
{
|
||||
if ($this->request->is('post')) {
|
||||
$data = $this->request->getData();
|
||||
$type = $data['type'];
|
||||
|
||||
$transaction = new \Proto\Gradido\GradidoTransaction();
|
||||
$transactionBody = new \Proto\Gradido\TransactionBody();
|
||||
$transactionBody->setMemo($data['memo']);
|
||||
$created = new \Proto\Gradido\TimestampSeconds();
|
||||
$now = new Time();
|
||||
$created->setSeconds($now->getTimestamp());
|
||||
$transactionBody->setCreated($created);
|
||||
if($type == "creation") {
|
||||
$creation = new \Proto\Gradido\GradidoCreation();
|
||||
$target_date = new \Proto\Gradido\TimestampSeconds();
|
||||
$target_time = new Time($data['target_date']);
|
||||
$target_date->setSeconds($target_time->getTimestamp());
|
||||
$creation->setTargetDate($target_date);
|
||||
$receiver = new \Proto\Gradido\TransferAmount();
|
||||
$receiver->setAmount(intval($data['amount']));
|
||||
$receiver->setPubkey(hex2bin($data['target_public_key']));
|
||||
$creation->setReceiver($receiver);
|
||||
$transactionBody->setCreation($creation);
|
||||
} else if($type == "transfer") {
|
||||
$transfer = new \Proto\Gradido\GradidoTransfer();
|
||||
$local_transfer = new \Proto\Gradido\LocalTransfer();
|
||||
$sender = new \Proto\Gradido\TransferAmount();
|
||||
$sender->setAmount(intval($data['amount']));
|
||||
$sender->setPubkey(hex2bin($data['sender_public_key']));
|
||||
$local_transfer->setSender($sender);
|
||||
$local_transfer->setReceiver(hex2bin($data['receiver_public_key']));
|
||||
$transfer->setLocal($local_transfer);
|
||||
$transactionBody->setTransfer($transfer);
|
||||
}
|
||||
$body_bytes = $transactionBody->serializeToString();
|
||||
$transaction->setBodyBytes($body_bytes);
|
||||
|
||||
$protoSigMap = new \Proto\Gradido\SignatureMap();
|
||||
$sigPairs = $protoSigMap->getSigPair();
|
||||
//echo "sigPairs: "; var_dump($sigPairs); echo "<br>";
|
||||
//return null;
|
||||
|
||||
// sign with keys
|
||||
//foreach($keys as $key) {
|
||||
$sigPair = new \Proto\Gradido\SignaturePair();
|
||||
$sigPair->setPubKey(hex2bin($data['signer_public_key']));
|
||||
|
||||
$signature = sodium_crypto_sign_detached($body_bytes, hex2bin($data['signer_private_key']));
|
||||
echo "signature: " . bin2hex($signature). "<br>";
|
||||
$sigPair->setEd25519($signature);
|
||||
|
||||
$sigPairs[] = $sigPair;
|
||||
// SODIUM_BASE64_VARIANT_URLSAFE_NO_PADDING
|
||||
// SODIUM_BASE64_VARIANT_ORIGINAL
|
||||
$transaction->setSigMap($protoSigMap);
|
||||
//var_dump($protoSigMap);
|
||||
$transaction_bin = $transaction->serializeToString();
|
||||
// $url_safe = sodium_bin2base64($transaction_bin, sodium_base64_VARIANT_ORIGINAL);
|
||||
$base64 = [
|
||||
//'original' => sodium_bin2base64($transaction_bin, sodium_base64_VARIANT_ORIGINAL),
|
||||
//'original_nopadding' => sodium_bin2base64($transaction_bin, sodium_base64_VARIANT_ORIGINAL_NO_PADDING),
|
||||
//'urlsafe' => sodium_bin2base64($transaction_bin, sodium_base64_VARIANT_URLSAFE),
|
||||
'urlsafe_nopadding' => sodium_bin2base64($transaction_bin, SODIUM_BASE64_VARIANT_URLSAFE_NO_PADDING),
|
||||
'php' => base64_encode($transaction_bin)
|
||||
|
||||
];
|
||||
|
||||
$this->set('base64', $base64);
|
||||
}
|
||||
}
|
||||
|
||||
public function decode()
|
||||
{
|
||||
$this->viewBuilder()->setLayout('frontend');
|
||||
|
||||
@ -1,96 +0,0 @@
|
||||
<?php
|
||||
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
# source: BasicTypes.proto
|
||||
|
||||
namespace Model\Messages\Gradido;
|
||||
|
||||
use Google\Protobuf\Internal\GPBType;
|
||||
use Google\Protobuf\Internal\RepeatedField;
|
||||
use Google\Protobuf\Internal\GPBUtil;
|
||||
|
||||
/**
|
||||
* Generated from protobuf message <code>model.messages.gradido.Key</code>
|
||||
*/
|
||||
class Key extends \Google\Protobuf\Internal\Message
|
||||
{
|
||||
protected $key;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param array $data {
|
||||
* Optional. Data for populating the Message object.
|
||||
*
|
||||
* @type string $ed25519
|
||||
* ed25519 signature (libsodium default)
|
||||
* @type string $ed25519_ref10
|
||||
* ed25519 ref10 signature
|
||||
* }
|
||||
*/
|
||||
public function __construct($data = NULL) {
|
||||
\GPBMetadata\BasicTypes::initOnce();
|
||||
parent::__construct($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* ed25519 signature (libsodium default)
|
||||
*
|
||||
* Generated from protobuf field <code>bytes ed25519 = 2;</code>
|
||||
* @return string
|
||||
*/
|
||||
public function getEd25519()
|
||||
{
|
||||
return $this->readOneof(2);
|
||||
}
|
||||
|
||||
/**
|
||||
* ed25519 signature (libsodium default)
|
||||
*
|
||||
* Generated from protobuf field <code>bytes ed25519 = 2;</code>
|
||||
* @param string $var
|
||||
* @return $this
|
||||
*/
|
||||
public function setEd25519($var)
|
||||
{
|
||||
GPBUtil::checkString($var, False);
|
||||
$this->writeOneof(2, $var);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* ed25519 ref10 signature
|
||||
*
|
||||
* Generated from protobuf field <code>bytes ed25519_ref10 = 3;</code>
|
||||
* @return string
|
||||
*/
|
||||
public function getEd25519Ref10()
|
||||
{
|
||||
return $this->readOneof(3);
|
||||
}
|
||||
|
||||
/**
|
||||
* ed25519 ref10 signature
|
||||
*
|
||||
* Generated from protobuf field <code>bytes ed25519_ref10 = 3;</code>
|
||||
* @param string $var
|
||||
* @return $this
|
||||
*/
|
||||
public function setEd25519Ref10($var)
|
||||
{
|
||||
GPBUtil::checkString($var, False);
|
||||
$this->writeOneof(3, $var);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getKey()
|
||||
{
|
||||
return $this->whichOneof("key");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,85 +0,0 @@
|
||||
<?php
|
||||
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
# source: BasicTypes.proto
|
||||
|
||||
namespace Model\Messages\Gradido;
|
||||
|
||||
use Google\Protobuf\Internal\GPBType;
|
||||
use Google\Protobuf\Internal\RepeatedField;
|
||||
use Google\Protobuf\Internal\GPBUtil;
|
||||
|
||||
/**
|
||||
* Generated from protobuf message <code>model.messages.gradido.ReceiverAmount</code>
|
||||
*/
|
||||
class ReceiverAmount extends \Google\Protobuf\Internal\Message
|
||||
{
|
||||
/**
|
||||
* Generated from protobuf field <code>bytes ed25519_receiver_pubkey = 1;</code>
|
||||
*/
|
||||
private $ed25519_receiver_pubkey = '';
|
||||
/**
|
||||
* Generated from protobuf field <code>sint64 amount = 2;</code>
|
||||
*/
|
||||
private $amount = 0;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param array $data {
|
||||
* Optional. Data for populating the Message object.
|
||||
*
|
||||
* @type string $ed25519_receiver_pubkey
|
||||
* @type int|string $amount
|
||||
* }
|
||||
*/
|
||||
public function __construct($data = NULL) {
|
||||
\GPBMetadata\BasicTypes::initOnce();
|
||||
parent::__construct($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated from protobuf field <code>bytes ed25519_receiver_pubkey = 1;</code>
|
||||
* @return string
|
||||
*/
|
||||
public function getEd25519ReceiverPubkey()
|
||||
{
|
||||
return $this->ed25519_receiver_pubkey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated from protobuf field <code>bytes ed25519_receiver_pubkey = 1;</code>
|
||||
* @param string $var
|
||||
* @return $this
|
||||
*/
|
||||
public function setEd25519ReceiverPubkey($var)
|
||||
{
|
||||
GPBUtil::checkString($var, False);
|
||||
$this->ed25519_receiver_pubkey = $var;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated from protobuf field <code>sint64 amount = 2;</code>
|
||||
* @return int|string
|
||||
*/
|
||||
public function getAmount()
|
||||
{
|
||||
return $this->amount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated from protobuf field <code>sint64 amount = 2;</code>
|
||||
* @param int|string $var
|
||||
* @return $this
|
||||
*/
|
||||
public function setAmount($var)
|
||||
{
|
||||
GPBUtil::checkInt64($var);
|
||||
$this->amount = $var;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,119 +0,0 @@
|
||||
<?php
|
||||
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
# source: BasicTypes.proto
|
||||
|
||||
namespace Model\Messages\Gradido;
|
||||
|
||||
use Google\Protobuf\Internal\GPBType;
|
||||
use Google\Protobuf\Internal\RepeatedField;
|
||||
use Google\Protobuf\Internal\GPBUtil;
|
||||
|
||||
/**
|
||||
* Generated from protobuf message <code>model.messages.gradido.SenderAmount</code>
|
||||
*/
|
||||
class SenderAmount extends \Google\Protobuf\Internal\Message
|
||||
{
|
||||
/**
|
||||
* Generated from protobuf field <code>bytes ed25519_sender_pubkey = 1;</code>
|
||||
*/
|
||||
private $ed25519_sender_pubkey = '';
|
||||
/**
|
||||
* Generated from protobuf field <code>sint64 amount = 2;</code>
|
||||
*/
|
||||
private $amount = 0;
|
||||
/**
|
||||
* sender balance after transaction, including perishability
|
||||
*
|
||||
* Generated from protobuf field <code>sint64 senderFinalBalance = 3;</code>
|
||||
*/
|
||||
private $senderFinalBalance = 0;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param array $data {
|
||||
* Optional. Data for populating the Message object.
|
||||
*
|
||||
* @type string $ed25519_sender_pubkey
|
||||
* @type int|string $amount
|
||||
* @type int|string $senderFinalBalance
|
||||
* sender balance after transaction, including perishability
|
||||
* }
|
||||
*/
|
||||
public function __construct($data = NULL) {
|
||||
\GPBMetadata\BasicTypes::initOnce();
|
||||
parent::__construct($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated from protobuf field <code>bytes ed25519_sender_pubkey = 1;</code>
|
||||
* @return string
|
||||
*/
|
||||
public function getEd25519SenderPubkey()
|
||||
{
|
||||
return $this->ed25519_sender_pubkey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated from protobuf field <code>bytes ed25519_sender_pubkey = 1;</code>
|
||||
* @param string $var
|
||||
* @return $this
|
||||
*/
|
||||
public function setEd25519SenderPubkey($var)
|
||||
{
|
||||
GPBUtil::checkString($var, False);
|
||||
$this->ed25519_sender_pubkey = $var;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated from protobuf field <code>sint64 amount = 2;</code>
|
||||
* @return int|string
|
||||
*/
|
||||
public function getAmount()
|
||||
{
|
||||
return $this->amount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated from protobuf field <code>sint64 amount = 2;</code>
|
||||
* @param int|string $var
|
||||
* @return $this
|
||||
*/
|
||||
public function setAmount($var)
|
||||
{
|
||||
GPBUtil::checkInt64($var);
|
||||
$this->amount = $var;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* sender balance after transaction, including perishability
|
||||
*
|
||||
* Generated from protobuf field <code>sint64 senderFinalBalance = 3;</code>
|
||||
* @return int|string
|
||||
*/
|
||||
public function getSenderFinalBalance()
|
||||
{
|
||||
return $this->senderFinalBalance;
|
||||
}
|
||||
|
||||
/**
|
||||
* sender balance after transaction, including perishability
|
||||
*
|
||||
* Generated from protobuf field <code>sint64 senderFinalBalance = 3;</code>
|
||||
* @param int|string $var
|
||||
* @return $this
|
||||
*/
|
||||
public function setSenderFinalBalance($var)
|
||||
{
|
||||
GPBUtil::checkInt64($var);
|
||||
$this->senderFinalBalance = $var;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,65 +0,0 @@
|
||||
<?php
|
||||
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
# source: BasicTypes.proto
|
||||
|
||||
namespace Model\Messages\Gradido;
|
||||
|
||||
use Google\Protobuf\Internal\GPBType;
|
||||
use Google\Protobuf\Internal\RepeatedField;
|
||||
use Google\Protobuf\Internal\GPBUtil;
|
||||
|
||||
/**
|
||||
* Generated from protobuf message <code>model.messages.gradido.SignatureMap</code>
|
||||
*/
|
||||
class SignatureMap extends \Google\Protobuf\Internal\Message
|
||||
{
|
||||
/**
|
||||
* Each signature pair corresponds to a unique Key required to sign the transaction.
|
||||
*
|
||||
* Generated from protobuf field <code>repeated .model.messages.gradido.SignaturePair sigPair = 1;</code>
|
||||
*/
|
||||
private $sigPair;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param array $data {
|
||||
* Optional. Data for populating the Message object.
|
||||
*
|
||||
* @type \Model\Messages\Gradido\SignaturePair[]|\Google\Protobuf\Internal\RepeatedField $sigPair
|
||||
* Each signature pair corresponds to a unique Key required to sign the transaction.
|
||||
* }
|
||||
*/
|
||||
public function __construct($data = NULL) {
|
||||
\GPBMetadata\BasicTypes::initOnce();
|
||||
parent::__construct($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Each signature pair corresponds to a unique Key required to sign the transaction.
|
||||
*
|
||||
* Generated from protobuf field <code>repeated .model.messages.gradido.SignaturePair sigPair = 1;</code>
|
||||
* @return \Google\Protobuf\Internal\RepeatedField
|
||||
*/
|
||||
public function getSigPair()
|
||||
{
|
||||
return $this->sigPair;
|
||||
}
|
||||
|
||||
/**
|
||||
* Each signature pair corresponds to a unique Key required to sign the transaction.
|
||||
*
|
||||
* Generated from protobuf field <code>repeated .model.messages.gradido.SignaturePair sigPair = 1;</code>
|
||||
* @param \Model\Messages\Gradido\SignaturePair[]|\Google\Protobuf\Internal\RepeatedField $var
|
||||
* @return $this
|
||||
*/
|
||||
public function setSigPair($var)
|
||||
{
|
||||
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Model\Messages\Gradido\SignaturePair::class);
|
||||
$this->sigPair = $arr;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,123 +0,0 @@
|
||||
<?php
|
||||
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
# source: BasicTypes.proto
|
||||
|
||||
namespace Model\Messages\Gradido;
|
||||
|
||||
use Google\Protobuf\Internal\GPBType;
|
||||
use Google\Protobuf\Internal\RepeatedField;
|
||||
use Google\Protobuf\Internal\GPBUtil;
|
||||
|
||||
/**
|
||||
* Generated from protobuf message <code>model.messages.gradido.SignaturePair</code>
|
||||
*/
|
||||
class SignaturePair extends \Google\Protobuf\Internal\Message
|
||||
{
|
||||
/**
|
||||
* Generated from protobuf field <code>bytes pubKey = 1;</code>
|
||||
*/
|
||||
private $pubKey = '';
|
||||
protected $signature;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param array $data {
|
||||
* Optional. Data for populating the Message object.
|
||||
*
|
||||
* @type string $pubKey
|
||||
* @type string $ed25519
|
||||
* ed25519 signature (libsodium default)
|
||||
* @type string $ed25519_ref10
|
||||
* ed25519 ref10 signature
|
||||
* }
|
||||
*/
|
||||
public function __construct($data = NULL) {
|
||||
\GPBMetadata\BasicTypes::initOnce();
|
||||
parent::__construct($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated from protobuf field <code>bytes pubKey = 1;</code>
|
||||
* @return string
|
||||
*/
|
||||
public function getPubKey()
|
||||
{
|
||||
return $this->pubKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated from protobuf field <code>bytes pubKey = 1;</code>
|
||||
* @param string $var
|
||||
* @return $this
|
||||
*/
|
||||
public function setPubKey($var)
|
||||
{
|
||||
GPBUtil::checkString($var, False);
|
||||
$this->pubKey = $var;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* ed25519 signature (libsodium default)
|
||||
*
|
||||
* Generated from protobuf field <code>bytes ed25519 = 2;</code>
|
||||
* @return string
|
||||
*/
|
||||
public function getEd25519()
|
||||
{
|
||||
return $this->readOneof(2);
|
||||
}
|
||||
|
||||
/**
|
||||
* ed25519 signature (libsodium default)
|
||||
*
|
||||
* Generated from protobuf field <code>bytes ed25519 = 2;</code>
|
||||
* @param string $var
|
||||
* @return $this
|
||||
*/
|
||||
public function setEd25519($var)
|
||||
{
|
||||
GPBUtil::checkString($var, False);
|
||||
$this->writeOneof(2, $var);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* ed25519 ref10 signature
|
||||
*
|
||||
* Generated from protobuf field <code>bytes ed25519_ref10 = 3;</code>
|
||||
* @return string
|
||||
*/
|
||||
public function getEd25519Ref10()
|
||||
{
|
||||
return $this->readOneof(3);
|
||||
}
|
||||
|
||||
/**
|
||||
* ed25519 ref10 signature
|
||||
*
|
||||
* Generated from protobuf field <code>bytes ed25519_ref10 = 3;</code>
|
||||
* @param string $var
|
||||
* @return $this
|
||||
*/
|
||||
public function setEd25519Ref10($var)
|
||||
{
|
||||
GPBUtil::checkString($var, False);
|
||||
$this->writeOneof(3, $var);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getSignature()
|
||||
{
|
||||
return $this->whichOneof("signature");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,114 +0,0 @@
|
||||
<?php
|
||||
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
# source: StateCreateGroup.proto
|
||||
|
||||
namespace Model\Messages\Gradido;
|
||||
|
||||
use Google\Protobuf\Internal\GPBType;
|
||||
use Google\Protobuf\Internal\RepeatedField;
|
||||
use Google\Protobuf\Internal\GPBUtil;
|
||||
|
||||
/**
|
||||
* need signature from this group and from parent (if it isn't zero)
|
||||
*
|
||||
* Generated from protobuf message <code>model.messages.gradido.StateCreateGroup</code>
|
||||
*/
|
||||
class StateCreateGroup extends \Google\Protobuf\Internal\Message
|
||||
{
|
||||
/**
|
||||
* Generated from protobuf field <code>string name = 1;</code>
|
||||
*/
|
||||
private $name = '';
|
||||
/**
|
||||
* Generated from protobuf field <code>.model.messages.gradido.Key groupPublicKey = 2;</code>
|
||||
*/
|
||||
private $groupPublicKey = null;
|
||||
/**
|
||||
* Generated from protobuf field <code>.model.messages.gradido.Key parentGroupPublicKey = 3;</code>
|
||||
*/
|
||||
private $parentGroupPublicKey = null;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param array $data {
|
||||
* Optional. Data for populating the Message object.
|
||||
*
|
||||
* @type string $name
|
||||
* @type \Model\Messages\Gradido\Key $groupPublicKey
|
||||
* @type \Model\Messages\Gradido\Key $parentGroupPublicKey
|
||||
* }
|
||||
*/
|
||||
public function __construct($data = NULL) {
|
||||
\GPBMetadata\StateCreateGroup::initOnce();
|
||||
parent::__construct($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated from protobuf field <code>string name = 1;</code>
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated from protobuf field <code>string name = 1;</code>
|
||||
* @param string $var
|
||||
* @return $this
|
||||
*/
|
||||
public function setName($var)
|
||||
{
|
||||
GPBUtil::checkString($var, True);
|
||||
$this->name = $var;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated from protobuf field <code>.model.messages.gradido.Key groupPublicKey = 2;</code>
|
||||
* @return \Model\Messages\Gradido\Key
|
||||
*/
|
||||
public function getGroupPublicKey()
|
||||
{
|
||||
return $this->groupPublicKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated from protobuf field <code>.model.messages.gradido.Key groupPublicKey = 2;</code>
|
||||
* @param \Model\Messages\Gradido\Key $var
|
||||
* @return $this
|
||||
*/
|
||||
public function setGroupPublicKey($var)
|
||||
{
|
||||
GPBUtil::checkMessage($var, \Model\Messages\Gradido\Key::class);
|
||||
$this->groupPublicKey = $var;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated from protobuf field <code>.model.messages.gradido.Key parentGroupPublicKey = 3;</code>
|
||||
* @return \Model\Messages\Gradido\Key
|
||||
*/
|
||||
public function getParentGroupPublicKey()
|
||||
{
|
||||
return $this->parentGroupPublicKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated from protobuf field <code>.model.messages.gradido.Key parentGroupPublicKey = 3;</code>
|
||||
* @param \Model\Messages\Gradido\Key $var
|
||||
* @return $this
|
||||
*/
|
||||
public function setParentGroupPublicKey($var)
|
||||
{
|
||||
GPBUtil::checkMessage($var, \Model\Messages\Gradido\Key::class);
|
||||
$this->parentGroupPublicKey = $var;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,114 +0,0 @@
|
||||
<?php
|
||||
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
# source: StateGroupChangeParent.proto
|
||||
|
||||
namespace Model\Messages\Gradido;
|
||||
|
||||
use Google\Protobuf\Internal\GPBType;
|
||||
use Google\Protobuf\Internal\RepeatedField;
|
||||
use Google\Protobuf\Internal\GPBUtil;
|
||||
|
||||
/**
|
||||
* need signature from this group and from both parents (if it isn't zero)
|
||||
*
|
||||
* Generated from protobuf message <code>model.messages.gradido.StateGroupChangeParent</code>
|
||||
*/
|
||||
class StateGroupChangeParent extends \Google\Protobuf\Internal\Message
|
||||
{
|
||||
/**
|
||||
* Generated from protobuf field <code>.model.messages.gradido.Key groupPublicKey = 1;</code>
|
||||
*/
|
||||
private $groupPublicKey = null;
|
||||
/**
|
||||
* Generated from protobuf field <code>.model.messages.gradido.Key newParentGroupPublicKey = 2;</code>
|
||||
*/
|
||||
private $newParentGroupPublicKey = null;
|
||||
/**
|
||||
* Generated from protobuf field <code>.model.messages.gradido.Key oldParentGroupPublicKey = 3;</code>
|
||||
*/
|
||||
private $oldParentGroupPublicKey = null;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param array $data {
|
||||
* Optional. Data for populating the Message object.
|
||||
*
|
||||
* @type \Model\Messages\Gradido\Key $groupPublicKey
|
||||
* @type \Model\Messages\Gradido\Key $newParentGroupPublicKey
|
||||
* @type \Model\Messages\Gradido\Key $oldParentGroupPublicKey
|
||||
* }
|
||||
*/
|
||||
public function __construct($data = NULL) {
|
||||
\GPBMetadata\StateGroupChangeParent::initOnce();
|
||||
parent::__construct($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated from protobuf field <code>.model.messages.gradido.Key groupPublicKey = 1;</code>
|
||||
* @return \Model\Messages\Gradido\Key
|
||||
*/
|
||||
public function getGroupPublicKey()
|
||||
{
|
||||
return $this->groupPublicKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated from protobuf field <code>.model.messages.gradido.Key groupPublicKey = 1;</code>
|
||||
* @param \Model\Messages\Gradido\Key $var
|
||||
* @return $this
|
||||
*/
|
||||
public function setGroupPublicKey($var)
|
||||
{
|
||||
GPBUtil::checkMessage($var, \Model\Messages\Gradido\Key::class);
|
||||
$this->groupPublicKey = $var;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated from protobuf field <code>.model.messages.gradido.Key newParentGroupPublicKey = 2;</code>
|
||||
* @return \Model\Messages\Gradido\Key
|
||||
*/
|
||||
public function getNewParentGroupPublicKey()
|
||||
{
|
||||
return $this->newParentGroupPublicKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated from protobuf field <code>.model.messages.gradido.Key newParentGroupPublicKey = 2;</code>
|
||||
* @param \Model\Messages\Gradido\Key $var
|
||||
* @return $this
|
||||
*/
|
||||
public function setNewParentGroupPublicKey($var)
|
||||
{
|
||||
GPBUtil::checkMessage($var, \Model\Messages\Gradido\Key::class);
|
||||
$this->newParentGroupPublicKey = $var;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated from protobuf field <code>.model.messages.gradido.Key oldParentGroupPublicKey = 3;</code>
|
||||
* @return \Model\Messages\Gradido\Key
|
||||
*/
|
||||
public function getOldParentGroupPublicKey()
|
||||
{
|
||||
return $this->oldParentGroupPublicKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated from protobuf field <code>.model.messages.gradido.Key oldParentGroupPublicKey = 3;</code>
|
||||
* @param \Model\Messages\Gradido\Key $var
|
||||
* @return $this
|
||||
*/
|
||||
public function setOldParentGroupPublicKey($var)
|
||||
{
|
||||
GPBUtil::checkMessage($var, \Model\Messages\Gradido\Key::class);
|
||||
$this->oldParentGroupPublicKey = $var;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,101 +0,0 @@
|
||||
<?php
|
||||
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
# source: BasicTypes.proto
|
||||
|
||||
namespace Model\Messages\Gradido;
|
||||
|
||||
use Google\Protobuf\Internal\GPBType;
|
||||
use Google\Protobuf\Internal\RepeatedField;
|
||||
use Google\Protobuf\Internal\GPBUtil;
|
||||
|
||||
/**
|
||||
* An exact date and time. This is the same data structure as the protobuf Timestamp.proto (see the comments in https://github.com/google/protobuf/blob/master/src/google/protobuf/timestamp.proto)
|
||||
*
|
||||
* Generated from protobuf message <code>model.messages.gradido.Timestamp</code>
|
||||
*/
|
||||
class Timestamp extends \Google\Protobuf\Internal\Message
|
||||
{
|
||||
/**
|
||||
* Number of complete seconds since the start of the epoch
|
||||
*
|
||||
* Generated from protobuf field <code>int64 seconds = 1;</code>
|
||||
*/
|
||||
private $seconds = 0;
|
||||
/**
|
||||
* Number of nanoseconds since the start of the last second
|
||||
*
|
||||
* Generated from protobuf field <code>int32 nanos = 2;</code>
|
||||
*/
|
||||
private $nanos = 0;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param array $data {
|
||||
* Optional. Data for populating the Message object.
|
||||
*
|
||||
* @type int|string $seconds
|
||||
* Number of complete seconds since the start of the epoch
|
||||
* @type int $nanos
|
||||
* Number of nanoseconds since the start of the last second
|
||||
* }
|
||||
*/
|
||||
public function __construct($data = NULL) {
|
||||
\GPBMetadata\BasicTypes::initOnce();
|
||||
parent::__construct($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Number of complete seconds since the start of the epoch
|
||||
*
|
||||
* Generated from protobuf field <code>int64 seconds = 1;</code>
|
||||
* @return int|string
|
||||
*/
|
||||
public function getSeconds()
|
||||
{
|
||||
return $this->seconds;
|
||||
}
|
||||
|
||||
/**
|
||||
* Number of complete seconds since the start of the epoch
|
||||
*
|
||||
* Generated from protobuf field <code>int64 seconds = 1;</code>
|
||||
* @param int|string $var
|
||||
* @return $this
|
||||
*/
|
||||
public function setSeconds($var)
|
||||
{
|
||||
GPBUtil::checkInt64($var);
|
||||
$this->seconds = $var;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Number of nanoseconds since the start of the last second
|
||||
*
|
||||
* Generated from protobuf field <code>int32 nanos = 2;</code>
|
||||
* @return int
|
||||
*/
|
||||
public function getNanos()
|
||||
{
|
||||
return $this->nanos;
|
||||
}
|
||||
|
||||
/**
|
||||
* Number of nanoseconds since the start of the last second
|
||||
*
|
||||
* Generated from protobuf field <code>int32 nanos = 2;</code>
|
||||
* @param int $var
|
||||
* @return $this
|
||||
*/
|
||||
public function setNanos($var)
|
||||
{
|
||||
GPBUtil::checkInt32($var);
|
||||
$this->nanos = $var;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,67 +0,0 @@
|
||||
<?php
|
||||
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
# source: BasicTypes.proto
|
||||
|
||||
namespace Model\Messages\Gradido;
|
||||
|
||||
use Google\Protobuf\Internal\GPBType;
|
||||
use Google\Protobuf\Internal\RepeatedField;
|
||||
use Google\Protobuf\Internal\GPBUtil;
|
||||
|
||||
/**
|
||||
* An exact date and time, with a resolution of one second (no nanoseconds).
|
||||
*
|
||||
* Generated from protobuf message <code>model.messages.gradido.TimestampSeconds</code>
|
||||
*/
|
||||
class TimestampSeconds extends \Google\Protobuf\Internal\Message
|
||||
{
|
||||
/**
|
||||
* Number of complete seconds since the start of the epoch
|
||||
*
|
||||
* Generated from protobuf field <code>int64 seconds = 1;</code>
|
||||
*/
|
||||
private $seconds = 0;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param array $data {
|
||||
* Optional. Data for populating the Message object.
|
||||
*
|
||||
* @type int|string $seconds
|
||||
* Number of complete seconds since the start of the epoch
|
||||
* }
|
||||
*/
|
||||
public function __construct($data = NULL) {
|
||||
\GPBMetadata\BasicTypes::initOnce();
|
||||
parent::__construct($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Number of complete seconds since the start of the epoch
|
||||
*
|
||||
* Generated from protobuf field <code>int64 seconds = 1;</code>
|
||||
* @return int|string
|
||||
*/
|
||||
public function getSeconds()
|
||||
{
|
||||
return $this->seconds;
|
||||
}
|
||||
|
||||
/**
|
||||
* Number of complete seconds since the start of the epoch
|
||||
*
|
||||
* Generated from protobuf field <code>int64 seconds = 1;</code>
|
||||
* @param int|string $var
|
||||
* @return $this
|
||||
*/
|
||||
public function setSeconds($var)
|
||||
{
|
||||
GPBUtil::checkInt64($var);
|
||||
$this->seconds = $var;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,166 +0,0 @@
|
||||
<?php
|
||||
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
# source: Transaction.proto
|
||||
|
||||
namespace Model\Messages\Gradido;
|
||||
|
||||
use Google\Protobuf\Internal\GPBType;
|
||||
use Google\Protobuf\Internal\RepeatedField;
|
||||
use Google\Protobuf\Internal\GPBUtil;
|
||||
|
||||
/**
|
||||
* Generated from protobuf message <code>model.messages.gradido.Transaction</code>
|
||||
*/
|
||||
class Transaction extends \Google\Protobuf\Internal\Message
|
||||
{
|
||||
/**
|
||||
* Generated from protobuf field <code>uint64 id = 1;</code>
|
||||
*/
|
||||
private $id = 0;
|
||||
/**
|
||||
* Generated from protobuf field <code>.model.messages.gradido.TimestampSeconds received = 2;</code>
|
||||
*/
|
||||
private $received = null;
|
||||
/**
|
||||
* Generated from protobuf field <code>.model.messages.gradido.SignatureMap sigMap = 3;</code>
|
||||
*/
|
||||
private $sigMap = null;
|
||||
/**
|
||||
* Generated from protobuf field <code>bytes txHash = 4;</code>
|
||||
*/
|
||||
private $txHash = '';
|
||||
/**
|
||||
* Generated from protobuf field <code>bytes bodyBytes = 5;</code>
|
||||
*/
|
||||
private $bodyBytes = '';
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param array $data {
|
||||
* Optional. Data for populating the Message object.
|
||||
*
|
||||
* @type int|string $id
|
||||
* @type \Model\Messages\Gradido\TimestampSeconds $received
|
||||
* @type \Model\Messages\Gradido\SignatureMap $sigMap
|
||||
* @type string $txHash
|
||||
* @type string $bodyBytes
|
||||
* }
|
||||
*/
|
||||
public function __construct($data = NULL) {
|
||||
\GPBMetadata\Transaction::initOnce();
|
||||
parent::__construct($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated from protobuf field <code>uint64 id = 1;</code>
|
||||
* @return int|string
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated from protobuf field <code>uint64 id = 1;</code>
|
||||
* @param int|string $var
|
||||
* @return $this
|
||||
*/
|
||||
public function setId($var)
|
||||
{
|
||||
GPBUtil::checkUint64($var);
|
||||
$this->id = $var;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated from protobuf field <code>.model.messages.gradido.TimestampSeconds received = 2;</code>
|
||||
* @return \Model\Messages\Gradido\TimestampSeconds
|
||||
*/
|
||||
public function getReceived()
|
||||
{
|
||||
return $this->received;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated from protobuf field <code>.model.messages.gradido.TimestampSeconds received = 2;</code>
|
||||
* @param \Model\Messages\Gradido\TimestampSeconds $var
|
||||
* @return $this
|
||||
*/
|
||||
public function setReceived($var)
|
||||
{
|
||||
GPBUtil::checkMessage($var, \Model\Messages\Gradido\TimestampSeconds::class);
|
||||
$this->received = $var;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated from protobuf field <code>.model.messages.gradido.SignatureMap sigMap = 3;</code>
|
||||
* @return \Model\Messages\Gradido\SignatureMap
|
||||
*/
|
||||
public function getSigMap()
|
||||
{
|
||||
return $this->sigMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated from protobuf field <code>.model.messages.gradido.SignatureMap sigMap = 3;</code>
|
||||
* @param \Model\Messages\Gradido\SignatureMap $var
|
||||
* @return $this
|
||||
*/
|
||||
public function setSigMap($var)
|
||||
{
|
||||
GPBUtil::checkMessage($var, \Model\Messages\Gradido\SignatureMap::class);
|
||||
$this->sigMap = $var;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated from protobuf field <code>bytes txHash = 4;</code>
|
||||
* @return string
|
||||
*/
|
||||
public function getTxHash()
|
||||
{
|
||||
return $this->txHash;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated from protobuf field <code>bytes txHash = 4;</code>
|
||||
* @param string $var
|
||||
* @return $this
|
||||
*/
|
||||
public function setTxHash($var)
|
||||
{
|
||||
GPBUtil::checkString($var, False);
|
||||
$this->txHash = $var;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated from protobuf field <code>bytes bodyBytes = 5;</code>
|
||||
* @return string
|
||||
*/
|
||||
public function getBodyBytes()
|
||||
{
|
||||
return $this->bodyBytes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated from protobuf field <code>bytes bodyBytes = 5;</code>
|
||||
* @param string $var
|
||||
* @return $this
|
||||
*/
|
||||
public function setBodyBytes($var)
|
||||
{
|
||||
GPBUtil::checkString($var, False);
|
||||
$this->bodyBytes = $var;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,193 +0,0 @@
|
||||
<?php
|
||||
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
# source: TransactionBody.proto
|
||||
|
||||
namespace Model\Messages\Gradido;
|
||||
|
||||
use Google\Protobuf\Internal\GPBType;
|
||||
use Google\Protobuf\Internal\RepeatedField;
|
||||
use Google\Protobuf\Internal\GPBUtil;
|
||||
|
||||
/**
|
||||
* Generated from protobuf message <code>model.messages.gradido.TransactionBody</code>
|
||||
*/
|
||||
class TransactionBody extends \Google\Protobuf\Internal\Message
|
||||
{
|
||||
/**
|
||||
* max 150 chars
|
||||
*
|
||||
* Generated from protobuf field <code>string memo = 1;</code>
|
||||
*/
|
||||
private $memo = '';
|
||||
/**
|
||||
* Generated from protobuf field <code>.model.messages.gradido.TimestampSeconds created = 2;</code>
|
||||
*/
|
||||
private $created = null;
|
||||
protected $data;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param array $data {
|
||||
* Optional. Data for populating the Message object.
|
||||
*
|
||||
* @type string $memo
|
||||
* max 150 chars
|
||||
* @type \Model\Messages\Gradido\TimestampSeconds $created
|
||||
* @type \Model\Messages\Gradido\StateCreateGroup $createGroup
|
||||
* @type \Model\Messages\Gradido\StateGroupChangeParent $groupChangeParent
|
||||
* @type \Model\Messages\Gradido\Transfer $transfer
|
||||
* @type \Model\Messages\Gradido\TransactionCreation $creation
|
||||
* }
|
||||
*/
|
||||
public function __construct($data = NULL) {
|
||||
\GPBMetadata\TransactionBody::initOnce();
|
||||
parent::__construct($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* max 150 chars
|
||||
*
|
||||
* Generated from protobuf field <code>string memo = 1;</code>
|
||||
* @return string
|
||||
*/
|
||||
public function getMemo()
|
||||
{
|
||||
return $this->memo;
|
||||
}
|
||||
|
||||
/**
|
||||
* max 150 chars
|
||||
*
|
||||
* Generated from protobuf field <code>string memo = 1;</code>
|
||||
* @param string $var
|
||||
* @return $this
|
||||
*/
|
||||
public function setMemo($var)
|
||||
{
|
||||
GPBUtil::checkString($var, True);
|
||||
$this->memo = $var;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated from protobuf field <code>.model.messages.gradido.TimestampSeconds created = 2;</code>
|
||||
* @return \Model\Messages\Gradido\TimestampSeconds
|
||||
*/
|
||||
public function getCreated()
|
||||
{
|
||||
return $this->created;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated from protobuf field <code>.model.messages.gradido.TimestampSeconds created = 2;</code>
|
||||
* @param \Model\Messages\Gradido\TimestampSeconds $var
|
||||
* @return $this
|
||||
*/
|
||||
public function setCreated($var)
|
||||
{
|
||||
GPBUtil::checkMessage($var, \Model\Messages\Gradido\TimestampSeconds::class);
|
||||
$this->created = $var;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated from protobuf field <code>.model.messages.gradido.StateCreateGroup createGroup = 6;</code>
|
||||
* @return \Model\Messages\Gradido\StateCreateGroup
|
||||
*/
|
||||
public function getCreateGroup()
|
||||
{
|
||||
return $this->readOneof(6);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated from protobuf field <code>.model.messages.gradido.StateCreateGroup createGroup = 6;</code>
|
||||
* @param \Model\Messages\Gradido\StateCreateGroup $var
|
||||
* @return $this
|
||||
*/
|
||||
public function setCreateGroup($var)
|
||||
{
|
||||
GPBUtil::checkMessage($var, \Model\Messages\Gradido\StateCreateGroup::class);
|
||||
$this->writeOneof(6, $var);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated from protobuf field <code>.model.messages.gradido.StateGroupChangeParent groupChangeParent = 7;</code>
|
||||
* @return \Model\Messages\Gradido\StateGroupChangeParent
|
||||
*/
|
||||
public function getGroupChangeParent()
|
||||
{
|
||||
return $this->readOneof(7);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated from protobuf field <code>.model.messages.gradido.StateGroupChangeParent groupChangeParent = 7;</code>
|
||||
* @param \Model\Messages\Gradido\StateGroupChangeParent $var
|
||||
* @return $this
|
||||
*/
|
||||
public function setGroupChangeParent($var)
|
||||
{
|
||||
GPBUtil::checkMessage($var, \Model\Messages\Gradido\StateGroupChangeParent::class);
|
||||
$this->writeOneof(7, $var);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated from protobuf field <code>.model.messages.gradido.Transfer transfer = 8;</code>
|
||||
* @return \Model\Messages\Gradido\Transfer
|
||||
*/
|
||||
public function getTransfer()
|
||||
{
|
||||
return $this->readOneof(8);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated from protobuf field <code>.model.messages.gradido.Transfer transfer = 8;</code>
|
||||
* @param \Model\Messages\Gradido\Transfer $var
|
||||
* @return $this
|
||||
*/
|
||||
public function setTransfer($var)
|
||||
{
|
||||
GPBUtil::checkMessage($var, \Model\Messages\Gradido\Transfer::class);
|
||||
$this->writeOneof(8, $var);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated from protobuf field <code>.model.messages.gradido.TransactionCreation creation = 9;</code>
|
||||
* @return \Model\Messages\Gradido\TransactionCreation
|
||||
*/
|
||||
public function getCreation()
|
||||
{
|
||||
return $this->readOneof(9);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated from protobuf field <code>.model.messages.gradido.TransactionCreation creation = 9;</code>
|
||||
* @param \Model\Messages\Gradido\TransactionCreation $var
|
||||
* @return $this
|
||||
*/
|
||||
public function setCreation($var)
|
||||
{
|
||||
GPBUtil::checkMessage($var, \Model\Messages\Gradido\TransactionCreation::class);
|
||||
$this->writeOneof(9, $var);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getData()
|
||||
{
|
||||
return $this->whichOneof("data");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,136 +0,0 @@
|
||||
<?php
|
||||
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
# source: TransactionCreation.proto
|
||||
|
||||
namespace Model\Messages\Gradido;
|
||||
|
||||
use Google\Protobuf\Internal\GPBType;
|
||||
use Google\Protobuf\Internal\RepeatedField;
|
||||
use Google\Protobuf\Internal\GPBUtil;
|
||||
|
||||
/**
|
||||
* need signature from group admin or
|
||||
* percent of group users another than the receiver
|
||||
*
|
||||
* Generated from protobuf message <code>model.messages.gradido.TransactionCreation</code>
|
||||
*/
|
||||
class TransactionCreation extends \Google\Protobuf\Internal\Message
|
||||
{
|
||||
/**
|
||||
* 40 Byte
|
||||
*
|
||||
* Generated from protobuf field <code>.model.messages.gradido.ReceiverAmount receiverAmount = 1;</code>
|
||||
*/
|
||||
private $receiverAmount = null;
|
||||
/**
|
||||
* 4 Byte
|
||||
*
|
||||
* Generated from protobuf field <code>sint32 ident_hash = 2;</code>
|
||||
*/
|
||||
private $ident_hash = 0;
|
||||
/**
|
||||
* 8 Byte
|
||||
*
|
||||
* Generated from protobuf field <code>.model.messages.gradido.TimestampSeconds target_date = 3;</code>
|
||||
*/
|
||||
private $target_date = null;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param array $data {
|
||||
* Optional. Data for populating the Message object.
|
||||
*
|
||||
* @type \Model\Messages\Gradido\ReceiverAmount $receiverAmount
|
||||
* 40 Byte
|
||||
* @type int $ident_hash
|
||||
* 4 Byte
|
||||
* @type \Model\Messages\Gradido\TimestampSeconds $target_date
|
||||
* 8 Byte
|
||||
* }
|
||||
*/
|
||||
public function __construct($data = NULL) {
|
||||
\GPBMetadata\TransactionCreation::initOnce();
|
||||
parent::__construct($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 40 Byte
|
||||
*
|
||||
* Generated from protobuf field <code>.model.messages.gradido.ReceiverAmount receiverAmount = 1;</code>
|
||||
* @return \Model\Messages\Gradido\ReceiverAmount
|
||||
*/
|
||||
public function getReceiverAmount()
|
||||
{
|
||||
return $this->receiverAmount;
|
||||
}
|
||||
|
||||
/**
|
||||
* 40 Byte
|
||||
*
|
||||
* Generated from protobuf field <code>.model.messages.gradido.ReceiverAmount receiverAmount = 1;</code>
|
||||
* @param \Model\Messages\Gradido\ReceiverAmount $var
|
||||
* @return $this
|
||||
*/
|
||||
public function setReceiverAmount($var)
|
||||
{
|
||||
GPBUtil::checkMessage($var, \Model\Messages\Gradido\ReceiverAmount::class);
|
||||
$this->receiverAmount = $var;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 4 Byte
|
||||
*
|
||||
* Generated from protobuf field <code>sint32 ident_hash = 2;</code>
|
||||
* @return int
|
||||
*/
|
||||
public function getIdentHash()
|
||||
{
|
||||
return $this->ident_hash;
|
||||
}
|
||||
|
||||
/**
|
||||
* 4 Byte
|
||||
*
|
||||
* Generated from protobuf field <code>sint32 ident_hash = 2;</code>
|
||||
* @param int $var
|
||||
* @return $this
|
||||
*/
|
||||
public function setIdentHash($var)
|
||||
{
|
||||
GPBUtil::checkInt32($var);
|
||||
$this->ident_hash = $var;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 8 Byte
|
||||
*
|
||||
* Generated from protobuf field <code>.model.messages.gradido.TimestampSeconds target_date = 3;</code>
|
||||
* @return \Model\Messages\Gradido\TimestampSeconds
|
||||
*/
|
||||
public function getTargetDate()
|
||||
{
|
||||
return $this->target_date;
|
||||
}
|
||||
|
||||
/**
|
||||
* 8 Byte
|
||||
*
|
||||
* Generated from protobuf field <code>.model.messages.gradido.TimestampSeconds target_date = 3;</code>
|
||||
* @param \Model\Messages\Gradido\TimestampSeconds $var
|
||||
* @return $this
|
||||
*/
|
||||
public function setTargetDate($var)
|
||||
{
|
||||
GPBUtil::checkMessage($var, \Model\Messages\Gradido\TimestampSeconds::class);
|
||||
$this->target_date = $var;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,85 +0,0 @@
|
||||
<?php
|
||||
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
# source: Transfer.proto
|
||||
|
||||
namespace Model\Messages\Gradido;
|
||||
|
||||
use Google\Protobuf\Internal\GPBType;
|
||||
use Google\Protobuf\Internal\RepeatedField;
|
||||
use Google\Protobuf\Internal\GPBUtil;
|
||||
|
||||
/**
|
||||
* Generated from protobuf message <code>model.messages.gradido.Transfer</code>
|
||||
*/
|
||||
class Transfer extends \Google\Protobuf\Internal\Message
|
||||
{
|
||||
/**
|
||||
* Generated from protobuf field <code>repeated .model.messages.gradido.SenderAmount senderAmounts = 1;</code>
|
||||
*/
|
||||
private $senderAmounts;
|
||||
/**
|
||||
* Generated from protobuf field <code>repeated .model.messages.gradido.ReceiverAmount receiverAmounts = 2;</code>
|
||||
*/
|
||||
private $receiverAmounts;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param array $data {
|
||||
* Optional. Data for populating the Message object.
|
||||
*
|
||||
* @type \Model\Messages\Gradido\SenderAmount[]|\Google\Protobuf\Internal\RepeatedField $senderAmounts
|
||||
* @type \Model\Messages\Gradido\ReceiverAmount[]|\Google\Protobuf\Internal\RepeatedField $receiverAmounts
|
||||
* }
|
||||
*/
|
||||
public function __construct($data = NULL) {
|
||||
\GPBMetadata\Transfer::initOnce();
|
||||
parent::__construct($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated from protobuf field <code>repeated .model.messages.gradido.SenderAmount senderAmounts = 1;</code>
|
||||
* @return \Google\Protobuf\Internal\RepeatedField
|
||||
*/
|
||||
public function getSenderAmounts()
|
||||
{
|
||||
return $this->senderAmounts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated from protobuf field <code>repeated .model.messages.gradido.SenderAmount senderAmounts = 1;</code>
|
||||
* @param \Model\Messages\Gradido\SenderAmount[]|\Google\Protobuf\Internal\RepeatedField $var
|
||||
* @return $this
|
||||
*/
|
||||
public function setSenderAmounts($var)
|
||||
{
|
||||
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Model\Messages\Gradido\SenderAmount::class);
|
||||
$this->senderAmounts = $arr;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated from protobuf field <code>repeated .model.messages.gradido.ReceiverAmount receiverAmounts = 2;</code>
|
||||
* @return \Google\Protobuf\Internal\RepeatedField
|
||||
*/
|
||||
public function getReceiverAmounts()
|
||||
{
|
||||
return $this->receiverAmounts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated from protobuf field <code>repeated .model.messages.gradido.ReceiverAmount receiverAmounts = 2;</code>
|
||||
* @param \Model\Messages\Gradido\ReceiverAmount[]|\Google\Protobuf\Internal\RepeatedField $var
|
||||
* @return $this
|
||||
*/
|
||||
public function setReceiverAmounts($var)
|
||||
{
|
||||
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Model\Messages\Gradido\ReceiverAmount::class);
|
||||
$this->receiverAmounts = $arr;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -25,7 +25,7 @@ class Transaction extends TransactionBase {
|
||||
//$transactionBin = base64_decode($base64Data, true);
|
||||
//if($transactionBin == false) {
|
||||
//sodium_base64_VARIANT_URLSAFE_NO_PADDING
|
||||
if(is_a($base64Data, '\Proto\Gradido\Transaction')) {
|
||||
if(is_a($base64Data, '\Proto\Gradido\GradidoTransaction')) {
|
||||
$this->mProtoTransaction = $base64Data;
|
||||
$this->mTransactionBody = new TransactionBody($this->mProtoTransaction->getBodyBytes());
|
||||
return;
|
||||
@ -93,7 +93,11 @@ class Transaction extends TransactionBase {
|
||||
return $this->mTransactionBody;
|
||||
}
|
||||
|
||||
public function getFirstPublic() {
|
||||
public function getFirstPublic()
|
||||
{
|
||||
if(!$this->mProtoTransaction || !$this->mProtoTransaction->getSigMap()) {
|
||||
return '';
|
||||
}
|
||||
$sigPairs = $this->mProtoTransaction->getSigMap()->getSigPair();
|
||||
return $sigPairs[0]->getPubKey();
|
||||
}
|
||||
@ -111,6 +115,7 @@ class Transaction extends TransactionBase {
|
||||
$sigMap = $this->mProtoTransaction->getSigMap();
|
||||
if(!$sigMap) {
|
||||
$this->addError('Transaction', 'signature map is zero');
|
||||
//var_dump($this->mProtoTransaction);
|
||||
return false;
|
||||
}
|
||||
//var_dump($sigMap);
|
||||
|
||||
@ -58,7 +58,7 @@ class TransactionTransfer extends TransactionBase {
|
||||
//$this->addError('TransactionTransfer::validate', 'not implemented yet');
|
||||
//return false;
|
||||
//$time = microtime(true);
|
||||
static $functionName = 'TransactionCreation::validate';
|
||||
static $functionName = 'TransactionTransfer::validate';
|
||||
|
||||
$sigPubHexs = [];
|
||||
foreach($sigPairs as $sigPair)
|
||||
|
||||
@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
$this->loadHelper('Form', [
|
||||
'templates' => 'horizontal_form',
|
||||
]);
|
||||
$now = new \DateTime;
|
||||
?>
|
||||
<?php if(isset($errors) && count($errors) > 0) : ?>
|
||||
<div class="alert-color">
|
||||
<ul>
|
||||
<?php foreach($errors as $error) : ?>
|
||||
<li>
|
||||
<?= var_dump($error); ?>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="action-form">
|
||||
<p class="form-header"><?= __('Creation Transaction') ?></p>
|
||||
<div class="form-body">
|
||||
<?= $this->Form->create() ?>
|
||||
<?= $this->Form->control('type', ['type' => 'hidden', 'value' => 'creation']) ?>
|
||||
<?= $this->Form->control('target_public_key', ['type'=> 'text']) ?>
|
||||
<?= $this->Form->control('target_date', ['type'=> 'text', 'placeholder' => 'yyyy-mm-dd hh:ii:ss', 'default' => $now->format('Y-m-d H:i:s')]) ?>
|
||||
<?= $this->Form->control('amount', ['type'=> 'number']) ?>
|
||||
<?= $this->Form->control('memo', ['type'=> 'textarea', 'rows' => '8', 'cols' => 40]) ?>
|
||||
<?= $this->Form->control('signer_public_key', ['type' => 'text']) ?>
|
||||
<?= $this->Form->control('signer_private_key', ['type'=> 'text']) ?>
|
||||
<?= $this->Form->submit(); ?>
|
||||
<?= $this->Form->end() ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="action-form">
|
||||
<p class="form-header"><?= __('Transfer Transaction') ?></p>
|
||||
<div class="form-body">
|
||||
<?= $this->Form->create() ?>
|
||||
<?= $this->Form->control('type', ['type' => 'hidden', 'value' => 'transfer']) ?>
|
||||
<?= $this->Form->control('sender_public_key', ['type'=> 'text']) ?>
|
||||
<?= $this->Form->control('receiver_public_key', ['type'=> 'text']) ?>
|
||||
<?= $this->Form->control('amount', ['type'=> 'number']) ?>
|
||||
<?= $this->Form->control('memo', ['type'=> 'textarea', 'rows' => '8', 'cols' => 40]) ?>
|
||||
<?= $this->Form->control('signer_public_key', ['type' => 'text']) ?>
|
||||
<?= $this->Form->control('signer_private_key', ['type'=> 'text']) ?>
|
||||
<?= $this->Form->submit(); ?>
|
||||
<?= $this->Form->end() ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php if(isset($base64)) : ?>
|
||||
<div>
|
||||
<ul>
|
||||
<?php foreach($base64 as $name => $value) : ?>
|
||||
<li><?= $name ?>: <?= $value ?></li>
|
||||
<?php endforeach ?>
|
||||
</ul>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
@ -6,7 +6,7 @@ use Cake\TestSuite\Fixture\TestFixture;
|
||||
/**
|
||||
* StateBalancesFixture
|
||||
*/
|
||||
class StateBalancesFixture extends TestFixture
|
||||
class StateBalancesFixture extends BaseTestFixture
|
||||
{
|
||||
/**
|
||||
* Fields
|
||||
@ -36,8 +36,11 @@ class StateBalancesFixture extends TestFixture
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
$this->records = [
|
||||
$sql = [
|
||||
[4, 4, '2021-05-27 17:47:50', '2021-05-27 17:47:50', 28808497],
|
||||
[5, 1, '2021-05-27 17:47:51', '2021-05-27 17:47:50', 9823963]
|
||||
];
|
||||
$this->records = $this->sqlEntrysToRecords($sql, $this->fields);
|
||||
parent::init();
|
||||
}
|
||||
}
|
||||
|
||||
@ -22,6 +22,7 @@ class JsonRequestHandlerControllerTest extends TestCase
|
||||
'app.TransactionCreations',
|
||||
'app.Transactions',
|
||||
'app.StateUsers',
|
||||
'app.StateUserTransactions',
|
||||
'app.StateErrors',
|
||||
'app.TransactionSignatures',
|
||||
'app.TransactionSendCoins',
|
||||
@ -31,10 +32,10 @@ class JsonRequestHandlerControllerTest extends TestCase
|
||||
|
||||
public $transactions = [
|
||||
'validCreation' => 'GmYKZAogYbkjwhjLY6ZKjGLzhgEhKDuVd_N00KMVkLoCzcKRKZkSQJ8wF12eZo3hcMAlAKKJ9WLT-zuSkNmGh7D98UEqH4KoIysnCkXqEya9EBZl9o11_nJ8xmm_nOevuVjR-GfLMQ8qSQoOSGFsbG8gV2VsdCAxMjMSBgiZm4ruBUovCicKIJSuE1uTzZ8zdStOVcQZA6P6oTp1u5C_1BHqHUoaXnEfEKDakwEQtYntlgo',
|
||||
'validCreation900' => 'GmYKZAogYbkjwhjLY6ZKjGLzhgEhKDuVd_N00KMVkLoCzcKRKZkSQNVZ8Ae3Zbg3G0wZ840fzKan6N4KtTcSe0KYi17kQwFmsl18oFxXv8_s6j1xXFrIKjy1_1Olq0a7xYLErDMkjwYqORIGCNb5iu4FSi8KJwoglK4TW5PNnzN1K05VxBkDo_qhOnW7kL_UEeodShpecR8QgNHKCBC1ie2WCg',
|
||||
'validCreation1200' => 'GmYKZAogYbkjwhjLY6ZKjGLzhgEhKDuVd_N00KMVkLoCzcKRKZkSQEEey5QMAdldoOTP_jTETHgOQriGsixEY0cziQeRfT_J5YtbI_A6AizEYD-JcxmRmXzv1xjjTgsV39Y32ta2CQkqORIGCIeGi-4FSi8KJwoglK4TW5PNnzN1K05VxBkDo_qhOnW7kL_UEeodShpecR8QgOy4CxC1ie2WCg',
|
||||
'validCreation900' => 'CmYKZAog9_SkmkrBA3n4ud3LcxxNnsSV5u3RYHX1JnLNJeMXnw8SQCaZHmvmvJOt336E3qst3rn1pptdAR5ZPzePaUT10x0_Yky8FnEiQtMGNy1yT94QErzwQudJZjJwDY2uyK4cTgkSOxIGCKb1vYUGOjEKJwog4zad42I86ERtBCTEAT56HXGiZxrj178eeY6_BmXRRfIQgNHKCBoGCIDMuf8F',
|
||||
'validCreation1200' => 'CmYKZAog9_SkmkrBA3n4ud3LcxxNnsSV5u3RYHX1JnLNJeMXnw8SQF8jptIrosEyVmCf3WEIGVOK0NR8YCcO0j-s8v2yUyR5BKus0ciT6B7IA5LDtn7eQX6zHjg1v5WlsTiZuOpuNgwSRAoHVG8gbXVjaBIGCL3Jv4UGOjEKJwog4zad42I86ERtBCTEAT56HXGiZxrj178eeY6_BmXRRfIQgOy4CxoGCOG5toQG',
|
||||
'notBase64' => 'CgpIYWxsbyBXZW-0EgYIyfSG7gV_LwonCiCboKikqwjZfes9xuqgthFH3',
|
||||
'validTransfer' => 'GmYKZAoggZC9pYXuXx2fv30G6B5p7BjhM3YQTP9Ut0V-t9PvcQ0SQDddHyKzAX3LBV0PuDiPc6lxkUipss5tyuLRpMtFJQnT30tsbYIkA1FXimjMKOoiuLswf4OLLV3bAIYehW-b9AgqYQoFSGFsbG8SBgiJlaPvBUJQCiYKIIGQvaWF7l8dn799BugeaewY4TN2EEz_VLdFfrfT73ENEICfSRImCiDtdleSLxhUgEbMW9DpqIwsykFj3-z_enKEOuGnXrmW8xCAn0k',
|
||||
'validTransfer' => 'CmYKZAog9_SkmkrBA3n4ud3LcxxNnsSV5u3RYHX1JnLNJeMXnw8SQA0ZVQ9T1qBabzmgDO1NAWNy2J6mlv0YjMP99CiV7bSR0zemt5XoM-kTviR1aTqKggzpSYSyTN5T6gIx2xa-hgkSYwoLTXkgQmlydGhkYXkSBgie0L-FBjJMCkoKJgog9_SkmkrBA3n4ud3LcxxNnsSV5u3RYHX1JnLNJeMXnw8QgIl6EiDjNp3jYjzoRG0EJMQBPnodcaJnGuPXvx55jr8GZdFF8g',
|
||||
'errornusTransfer' => 'ClxGcm9oZXMgTmV1ZXMgSmFociB1bmQgREFOS0UsIGRhc3MgZHUgZGljaCBzbyBlaW5zZXR6dCBmw7xyIEdyYWRpZG8hIEhlcnpsaWNoZSBHcsO8w59lIFRlcmVzYRIGCPjjgvEFQlAKJgogUQwFYeVlGlfWDrkXNN7rHwejoCDJKt+YkYJfbJVyj3EQwIQ9EiYKIPXIRnUhVJ/zCs5+y/VaTBjTIoYizJNwS+JC//xsbQrHEMCEPQ==',
|
||||
'creationValid' => 'GmYKZAogLtKKHPXhFtg2FUBrxXcVIiHC93SlZW9moOdUD3V21xsSQHpXYAGiVmSfhjB3o7OPx0ZJuPXrDk5eu1_AOhQBODU3KpUqBRA9yMX54S_mvGijGubCNRcMLcm7wiYbyAG-3AkqSwoQZWluIE1vbmF0c2dlaGFsdBIGCKqs5vEFSi8KJwoggZC9pYXuXx2fv30G6B5p7BjhM3YQTP9Ut0V-t9PvcQ0QgNrECRDKyd3uAQ'
|
||||
];
|
||||
@ -51,7 +52,7 @@ class JsonRequestHandlerControllerTest extends TestCase
|
||||
$this->get('/JsonRequestHandler');
|
||||
$this->assertResponseOk();
|
||||
|
||||
$expected = json_encode(['state' => 'error', 'msg' => 'no post']);
|
||||
$expected = json_encode(['state' => 'error', 'msg' => 'unknown method for get', 'details' => null]);
|
||||
$this->assertEquals($expected, (string)$this->_response->getBody());
|
||||
}
|
||||
|
||||
@ -87,7 +88,7 @@ class JsonRequestHandlerControllerTest extends TestCase
|
||||
//$this->post('/TransactionJsonRequestHandler', ['method' => 'putTransaction', 'transaction' => 'CgpIYWxsbyBXZWx0EgYIyfSG7gVKLwonCiCboKikqwjZfes9xuqgthFH3/cHHaWchkUhWiGhQjB23xCg2pMBELWJ7ZYK']);
|
||||
$this->postAndParse(
|
||||
['method' => 'foobar', 'transaction' => $this->transactions['validCreation']],
|
||||
['state' => 'error', 'msg' => 'unknown method', 'details' => 'foobar']
|
||||
['state' => 'error', 'msg' => 'unknown method for post', 'details' => 'foobar']
|
||||
);
|
||||
|
||||
}
|
||||
@ -97,7 +98,8 @@ class JsonRequestHandlerControllerTest extends TestCase
|
||||
$this->postAndParse(
|
||||
['method' => 'putTransaction', 'transaction' => $this->transactions['notBase64']],
|
||||
['state' => 'error', 'msg' => 'error parsing transaction', 'details' => [
|
||||
['Transaction' => 'invalid base64 string']
|
||||
['Transaction' => 'invalid base64 string'],
|
||||
['base64' => 'CgpIYWxsbyBXZW-0EgYIyfSG7gV_LwonCiCboKikqwjZfes9xuqgthFH3']
|
||||
]]
|
||||
);
|
||||
}
|
||||
@ -114,9 +116,10 @@ class JsonRequestHandlerControllerTest extends TestCase
|
||||
|
||||
public function testToLargeCreationSum()
|
||||
{
|
||||
|
||||
$this->postAndParse(
|
||||
['method' => 'putTransaction', 'transaction' => $this->transactions['validCreation900']],
|
||||
'{"state":"error","msg":"error validate transaction","details":[{"TransactionCreation::validate":"Creation more than 1000 gr per Month not allowed"}]}'
|
||||
'{"state":"error","msg":"error validate transaction","details":[{"TransactionCreation::validate":"Creation more than 1.000 GDD per Month for in target_date not allowed"}]}'
|
||||
);
|
||||
}
|
||||
|
||||
@ -124,7 +127,7 @@ class JsonRequestHandlerControllerTest extends TestCase
|
||||
{
|
||||
$this->postAndParse(
|
||||
['method' => 'putTransaction', 'transaction' => $this->transactions['validCreation1200']],
|
||||
'{"state":"error","msg":"error validate transaction","details":[{"TransactionCreation::validate":"Creation more than 1000 gr per Month not allowed"}]}'
|
||||
'{"state":"error","msg":"error validate transaction","details":[{"TransactionCreation::validate":"Creation more than 1.000 GDD per Month for in target_date not allowed"}]}'
|
||||
);
|
||||
}
|
||||
|
||||
@ -159,14 +162,14 @@ class JsonRequestHandlerControllerTest extends TestCase
|
||||
|
||||
private function postAndParse($params, $expected)
|
||||
{
|
||||
//$this->enableCsrfToken();
|
||||
$this->enableCsrfToken();
|
||||
//$this->enableSecurityToken();
|
||||
|
||||
$token = 'my-csrf-token';
|
||||
$this->cookie('csrfToken', $token);
|
||||
//$token = 'my-csrf-token';
|
||||
//$this->cookie('csrfToken', $token);
|
||||
|
||||
$this->configRequest([
|
||||
'headers' => ['Accept' => 'application/json', 'X-CSRF-Token' => $token]
|
||||
'headers' => ['Accept' => 'application/json']//, 'X-CSRF-Token' => $token]
|
||||
]);
|
||||
|
||||
$this->disableErrorHandlerMiddleware();
|
||||
|
||||
@ -1,174 +0,0 @@
|
||||
<?php
|
||||
namespace App\Test\TestCase\Controller;
|
||||
|
||||
use App\Controller\JsonRequestHandlerController;
|
||||
use Cake\TestSuite\IntegrationTestTrait;
|
||||
use Cake\TestSuite\TestCase;
|
||||
|
||||
/**
|
||||
* App\Controller\TransactionJsonRequestHandlerController Test Case
|
||||
*
|
||||
* @uses \App\Controller\TransactionJsonRequestHandlerController
|
||||
*/
|
||||
class TransactionJsonRequestHandlerControllerTest extends TestCase
|
||||
{
|
||||
use IntegrationTestTrait;
|
||||
|
||||
/**
|
||||
* Fixtures
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $fixtures = [
|
||||
'app.TransactionCreations',
|
||||
'app.Transactions',
|
||||
'app.StateUsers',
|
||||
'app.StateErrors',
|
||||
'app.TransactionSignatures',
|
||||
'app.TransactionSendCoins',
|
||||
'app.StateBalances',
|
||||
'app.TransactionTypes'
|
||||
];
|
||||
|
||||
public $transactions = [
|
||||
'validCreation' => 'GmYKZAogYbkjwhjLY6ZKjGLzhgEhKDuVd_N00KMVkLoCzcKRKZkSQJ8wF12eZo3hcMAlAKKJ9WLT-zuSkNmGh7D98UEqH4KoIysnCkXqEya9EBZl9o11_nJ8xmm_nOevuVjR-GfLMQ8qSQoOSGFsbG8gV2VsdCAxMjMSBgiZm4ruBUovCicKIJSuE1uTzZ8zdStOVcQZA6P6oTp1u5C_1BHqHUoaXnEfEKDakwEQtYntlgo',
|
||||
'validCreation900' => 'GmYKZAogYbkjwhjLY6ZKjGLzhgEhKDuVd_N00KMVkLoCzcKRKZkSQNVZ8Ae3Zbg3G0wZ840fzKan6N4KtTcSe0KYi17kQwFmsl18oFxXv8_s6j1xXFrIKjy1_1Olq0a7xYLErDMkjwYqORIGCNb5iu4FSi8KJwoglK4TW5PNnzN1K05VxBkDo_qhOnW7kL_UEeodShpecR8QgNHKCBC1ie2WCg',
|
||||
'validCreation1200' => 'GmYKZAogYbkjwhjLY6ZKjGLzhgEhKDuVd_N00KMVkLoCzcKRKZkSQEEey5QMAdldoOTP_jTETHgOQriGsixEY0cziQeRfT_J5YtbI_A6AizEYD-JcxmRmXzv1xjjTgsV39Y32ta2CQkqORIGCIeGi-4FSi8KJwoglK4TW5PNnzN1K05VxBkDo_qhOnW7kL_UEeodShpecR8QgOy4CxC1ie2WCg',
|
||||
'notBase64' => 'CgpIYWxsbyBXZW-0EgYIyfSG7gV_LwonCiCboKikqwjZfes9xuqgthFH3',
|
||||
'validTransfer' => 'GmYKZAoggZC9pYXuXx2fv30G6B5p7BjhM3YQTP9Ut0V-t9PvcQ0SQDddHyKzAX3LBV0PuDiPc6lxkUipss5tyuLRpMtFJQnT30tsbYIkA1FXimjMKOoiuLswf4OLLV3bAIYehW-b9AgqYQoFSGFsbG8SBgiJlaPvBUJQCiYKIIGQvaWF7l8dn799BugeaewY4TN2EEz_VLdFfrfT73ENEICfSRImCiDtdleSLxhUgEbMW9DpqIwsykFj3-z_enKEOuGnXrmW8xCAn0k',
|
||||
'errornusTransfer' => 'ClxGcm9oZXMgTmV1ZXMgSmFociB1bmQgREFOS0UsIGRhc3MgZHUgZGljaCBzbyBlaW5zZXR6dCBmw7xyIEdyYWRpZG8hIEhlcnpsaWNoZSBHcsO8w59lIFRlcmVzYRIGCPjjgvEFQlAKJgogUQwFYeVlGlfWDrkXNN7rHwejoCDJKt+YkYJfbJVyj3EQwIQ9EiYKIPXIRnUhVJ/zCs5+y/VaTBjTIoYizJNwS+JC//xsbQrHEMCEPQ=='
|
||||
];
|
||||
|
||||
/*public function setUp() {
|
||||
parent::setUp();
|
||||
}
|
||||
*/
|
||||
public function testWrongMethod()
|
||||
{
|
||||
$this->configRequest([
|
||||
'headers' => ['Accept' => 'application/json']
|
||||
]);
|
||||
$this->get('/TransactionJsonRequestHandler');
|
||||
$this->assertResponseOk();
|
||||
|
||||
$expected = json_encode(['state' => 'error', 'msg' => 'no post']);
|
||||
$this->assertEquals($expected, (string)$this->_response->getBody());
|
||||
}
|
||||
|
||||
public function testInvalidJson()
|
||||
{
|
||||
$this->configRequest([
|
||||
'headers' => ['Accept' => 'application/json']
|
||||
]);
|
||||
$this->post('/TransactionJsonRequestHandler', '{This isn\'t valid json}');
|
||||
$this->assertResponseOk();
|
||||
|
||||
$expected = json_encode(['state' => 'error', 'msg' => 'parameter error']);
|
||||
$this->assertEquals($expected, (string)$this->_response->getBody());
|
||||
}
|
||||
|
||||
public function testNotSetTransaction()
|
||||
{
|
||||
$this->postAndParse(
|
||||
['method' => 'putTransaction'],
|
||||
['state' => 'error', 'msg' => 'parameter error']
|
||||
);
|
||||
}
|
||||
public function testNotSetMethod()
|
||||
{
|
||||
$this->postAndParse(
|
||||
['transaction' => $this->transactions['validCreation']],
|
||||
['state' => 'error', 'msg' => 'parameter error']
|
||||
);
|
||||
}
|
||||
|
||||
public function testUnknownMethod()
|
||||
{
|
||||
//$this->post('/TransactionJsonRequestHandler', ['method' => 'putTransaction', 'transaction' => 'CgpIYWxsbyBXZWx0EgYIyfSG7gVKLwonCiCboKikqwjZfes9xuqgthFH3/cHHaWchkUhWiGhQjB23xCg2pMBELWJ7ZYK']);
|
||||
$this->postAndParse(
|
||||
['method' => 'foobar', 'transaction' => $this->transactions['validCreation']],
|
||||
['state' => 'error', 'msg' => 'unknown method', 'details' => 'foobar']
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
public function testInvalidEncodedTransaction() {
|
||||
//"msg":"error parsing transaction","details":[{"Transaction":"base64 decode error"}]
|
||||
$this->postAndParse(
|
||||
['method' => 'putTransaction', 'transaction' => $this->transactions['notBase64']],
|
||||
['state' => 'error', 'msg' => 'error parsing transaction', 'details' => [
|
||||
['Transaction' => 'invalid base64 string']
|
||||
]]
|
||||
);
|
||||
}
|
||||
|
||||
public function testInvalidTransaction() {
|
||||
|
||||
$this->postAndParse(
|
||||
['method' => 'putTransaction', 'transaction' => base64_encode('Hallo Miau Welt')],
|
||||
['state' => 'error', 'msg' => 'error parsing transaction', 'details' => [
|
||||
['Transaction' => 'Error occurred during parsing: Unexpected wire type.']
|
||||
]]
|
||||
);
|
||||
}
|
||||
|
||||
public function testToLargeCreationSum()
|
||||
{
|
||||
$this->postAndParse(
|
||||
['method' => 'putTransaction', 'transaction' => $this->transactions['validCreation900']],
|
||||
'{"state":"error","msg":"error validate transaction","details":[{"TransactionCreation::validate":"Creation more than 1000 gr per Month not allowed"}]}'
|
||||
);
|
||||
}
|
||||
|
||||
public function testToLargeCreation()
|
||||
{
|
||||
$this->postAndParse(
|
||||
['method' => 'putTransaction', 'transaction' => $this->transactions['validCreation1200']],
|
||||
'{"state":"error","msg":"error validate transaction","details":[{"TransactionCreation::validate":"Creation more than 1000 gr per Month not allowed"}]}'
|
||||
);
|
||||
}
|
||||
|
||||
public function testValidTransfer()
|
||||
{
|
||||
$this->postAndParse(
|
||||
['method' => 'putTransaction', 'transaction' => $this->transactions['validTransfer']],
|
||||
['state' => 'success']
|
||||
);
|
||||
}
|
||||
|
||||
/*public function testMissingPreviousTransaction()
|
||||
{
|
||||
|
||||
}*/
|
||||
|
||||
public function testValidTransaction()
|
||||
{
|
||||
$this->postAndParse(
|
||||
['method' => 'putTransaction', 'transaction' => $this->transactions['validCreation']],
|
||||
['state' => 'success']
|
||||
);
|
||||
}
|
||||
|
||||
private function postAndParse($params, $expected)
|
||||
{
|
||||
|
||||
$this->configRequest([
|
||||
'headers' => ['Accept' => 'application/json']
|
||||
]);
|
||||
|
||||
$this->disableErrorHandlerMiddleware();
|
||||
$this->post('/TransactionJsonRequestHandler', json_encode($params));
|
||||
|
||||
// Check that the response was a 200
|
||||
$this->assertResponseOk();
|
||||
|
||||
$responseBodyString = (string)$this->_response->getBody();
|
||||
$json = json_decode($responseBodyString);
|
||||
$this->assertNotFalse($json);
|
||||
|
||||
if(is_array($expected)) {
|
||||
$expected = json_encode($expected);
|
||||
}
|
||||
$this->assertEquals($expected, $responseBodyString);
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user