Skip to content

Commit

Permalink
BalanceChanges rename issuer to counterparty
Browse files Browse the repository at this point in the history
  • Loading branch information
zgrguric committed Nov 2, 2022
1 parent e3cb108 commit 47a6c7e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
6 changes: 3 additions & 3 deletions src/Utilities/BalanceChanges.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ private function getTrustlineQuantity(\stdClass $node): ?array
$result = [
'account' => (isset($fields->LowLimit->issuer)) ? $fields->LowLimit->issuer : '',
'balance' => [
'issuer' => (isset($fields->HighLimit->issuer)) ? $fields->HighLimit->issuer : '',
'counterparty' => (isset($fields->HighLimit->issuer)) ? $fields->HighLimit->issuer : '',
'currency' => (isset($fields->Balance->currency)) ? $fields->Balance->currency : '',
'value' => (string)$value->stripTrailingZeros(),
]
Expand Down Expand Up @@ -155,9 +155,9 @@ private function flipTrustlinePerspective(array $balanceChange): array
{
$negatedBalance = BigDecimal::of($balanceChange['balance']['value'])->negated();
$result = [
'account' => $balanceChange['balance']['issuer'],
'account' => $balanceChange['balance']['counterparty'],
'balance' => [
'issuer' => $balanceChange['account'],
'counterparty' => $balanceChange['account'],
'currency' => $balanceChange['balance']['currency'],
'value' => (string)$negatedBalance->stripTrailingZeros(),
]
Expand Down
36 changes: 18 additions & 18 deletions tests/Unit/BalanceChangesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function test_usd_payment_to_account_with_no_usd()
[
'value' => '-0.01',
'currency' => 'USD',
'issuer' => 'rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q'
'counterparty' => 'rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q'
],
[
'value' => '-0.012',
Expand All @@ -59,12 +59,12 @@ public function test_usd_payment_to_account_with_no_usd()
[
'value' => '0.01',
'currency' => 'USD',
'issuer' => 'rKmBGxocj9Abgy25J51Mk1iqFzW9aVF9Tc'
'counterparty' => 'rKmBGxocj9Abgy25J51Mk1iqFzW9aVF9Tc'
],
[
'value' => '-0.01',
'currency' => 'USD',
'issuer' => 'rLDYrujdKUfVx28T9vRDAbyJ7G2WVXKo4K'
'counterparty' => 'rLDYrujdKUfVx28T9vRDAbyJ7G2WVXKo4K'
]
]
],
Expand All @@ -74,7 +74,7 @@ public function test_usd_payment_to_account_with_no_usd()
[
'value' => '0.01',
'currency' => 'USD',
'issuer' => 'rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q'
'counterparty' => 'rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q'
]
]
]
Expand All @@ -97,7 +97,7 @@ public function test_payment_of_all_usd_in_source_account()
[
'value' => '0.2',
'currency' => 'USD',
'issuer' => 'rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q'
'counterparty' => 'rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q'
]
]
],
Expand All @@ -107,12 +107,12 @@ public function test_payment_of_all_usd_in_source_account()
[
'value' => '-0.2',
'currency' => 'USD',
'issuer' => 'rKmBGxocj9Abgy25J51Mk1iqFzW9aVF9Tc'
'counterparty' => 'rKmBGxocj9Abgy25J51Mk1iqFzW9aVF9Tc'
],
[
'value' => '0.2',
'currency' => 'USD',
'issuer' => 'rLDYrujdKUfVx28T9vRDAbyJ7G2WVXKo4K'
'counterparty' => 'rLDYrujdKUfVx28T9vRDAbyJ7G2WVXKo4K'
]
]
],
Expand All @@ -122,7 +122,7 @@ public function test_payment_of_all_usd_in_source_account()
[
'value' => '-0.2',
'currency' => 'USD',
'issuer' => 'rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q'
'counterparty' => 'rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q'
],
[
'value' => '-0.012',
Expand All @@ -149,7 +149,7 @@ public function test_usd_payment_to_account_with_usd()
[
'value' => '-0.01',
'currency' => 'USD',
'issuer' => 'rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q'
'counterparty' => 'rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q'
],
[
'value' => '-0.012',
Expand All @@ -163,12 +163,12 @@ public function test_usd_payment_to_account_with_usd()
[
'value' => '0.01',
'currency' => 'USD',
'issuer' => 'rKmBGxocj9Abgy25J51Mk1iqFzW9aVF9Tc'
'counterparty' => 'rKmBGxocj9Abgy25J51Mk1iqFzW9aVF9Tc'
],
[
'value' => '-0.01',
'currency' => 'USD',
'issuer' => 'rLDYrujdKUfVx28T9vRDAbyJ7G2WVXKo4K'
'counterparty' => 'rLDYrujdKUfVx28T9vRDAbyJ7G2WVXKo4K'
]
]
],
Expand All @@ -178,7 +178,7 @@ public function test_usd_payment_to_account_with_usd()
[
'value' => '0.01',
'currency' => 'USD',
'issuer' => 'rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q'
'counterparty' => 'rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q'
]
]
]
Expand Down Expand Up @@ -223,7 +223,7 @@ public function test_create_trustline()
[
'value' => '10',
'currency' => 'USD',
'issuer' => 'rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q',
'counterparty' => 'rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q',
],
[
'value' => '-0.012',
Expand All @@ -237,7 +237,7 @@ public function test_create_trustline()
[
'value' => '-10',
'currency' => 'USD',
'issuer' => 'rLDYrujdKUfVx28T9vRDAbyJ7G2WVXKo4K',
'counterparty' => 'rLDYrujdKUfVx28T9vRDAbyJ7G2WVXKo4K',
]
]
]
Expand Down Expand Up @@ -304,7 +304,7 @@ public function test_delete_trustline()
[
'value' => '0.02',
'currency' => 'USD',
'issuer' => 'rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q'
'counterparty' => 'rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q'
]
],
],
Expand All @@ -314,12 +314,12 @@ public function test_delete_trustline()
[
'value' => '-0.02',
'currency' => 'USD',
'issuer' => 'rKmBGxocj9Abgy25J51Mk1iqFzW9aVF9Tc'
'counterparty' => 'rKmBGxocj9Abgy25J51Mk1iqFzW9aVF9Tc'
],
[
'value' => '0.02',
'currency' => 'USD',
'issuer' => 'rLDYrujdKUfVx28T9vRDAbyJ7G2WVXKo4K'
'counterparty' => 'rLDYrujdKUfVx28T9vRDAbyJ7G2WVXKo4K'
]
]
],
Expand All @@ -329,7 +329,7 @@ public function test_delete_trustline()
[
'value' => '-0.02',
'currency' => 'USD',
'issuer' => 'rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q'
'counterparty' => 'rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q'
],
[
'value' => '-0.012',
Expand Down

0 comments on commit 47a6c7e

Please sign in to comment.