Skip to content

Commit

Permalink
Promote transactionHash to Operation from Payment
Browse files Browse the repository at this point in the history
Fixes #28
  • Loading branch information
zulucrypto committed Sep 22, 2018
1 parent d7c963b commit 7e11eca
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 16 deletions.
6 changes: 4 additions & 2 deletions getting-started/06-list-payments.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@

$seenResults = 0;
foreach ($payments as $payment) {
/** @var $payment \ZuluCrypto\StellarSdk\Model\Operation|\ZuluCrypto\StellarSdk\Model\AssetTransferInterface */
// If the same cursor shows up twice, we're repeating results and should exit
if ($payment->getPagingToken() == $currentCursor) break 2;

printf('[%s] Amount: %s From %s' . PHP_EOL,
printf('[%s] Amount: %s From %s in Tx %s' . PHP_EOL,
$payment->getAssetTransferType(),
$payment->getAssetAmount(),
$payment->getFromAccountId()
$payment->getFromAccountId(),
$payment->getTransactionHash()
);

$currentCursor = $payment->getPagingToken();
Expand Down
14 changes: 14 additions & 0 deletions src/Model/Operation.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ class Operation extends RestApiModel
*/
protected $typeI;

/**
* @var string
*/
protected $transactionHash;

/**
* @param array $rawData
* @return Operation
Expand Down Expand Up @@ -120,6 +125,7 @@ public function loadFromRawResponseData($rawData)
$this->typeI = $rawData['type_i'];

if (isset($rawData['paging_token'])) $this->pagingToken = $rawData['paging_token'];
if (isset($rawData['transaction_hash'])) $this->transactionHash = $rawData['transaction_hash'];
}

/**
Expand Down Expand Up @@ -169,4 +175,12 @@ public function setTypeI($typeI)
{
$this->typeI = $typeI;
}

/**
* @return string
*/
public function getTransactionHash()
{
return $this->transactionHash;
}
}
14 changes: 0 additions & 14 deletions src/Model/Payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ class Payment extends Operation implements AssetTransferInterface
* @var string
*/
private $toAccountId;

/**
* @var string
*/
private $transactionHash;

/**
* @var AssetAmount
Expand Down Expand Up @@ -89,7 +84,6 @@ public function loadFromRawResponseData($rawData)

if (isset($rawData['from'])) $this->fromAccountId = $rawData['from'];
if (isset($rawData['to'])) $this->toAccountId = $rawData['to'];
if (isset($rawData['transaction_hash'])) $this->transactionHash = $rawData['transaction_hash'];

$assetAmount = null;
// Native assets
Expand Down Expand Up @@ -195,12 +189,4 @@ public function setAmount(AssetAmount $amount)
{
$this->amount = $amount;
}

/**
* @return string
*/
public function getTransactionHash()
{
return $this->transactionHash;
}
}

0 comments on commit 7e11eca

Please sign in to comment.