Remove empty counterparties in XRP amounts

This commit is contained in:
Chris Clark
2015-06-18 17:33:35 -07:00
parent 22cd70e53f
commit 1ccca1c4ec
3 changed files with 22 additions and 9 deletions

View File

@@ -13,6 +13,26 @@ function removeUndefined(obj: ?Object): ?Object {
return obj ? _.omit(obj, _.isUndefined) : obj;
}
function removeEmptyCounterparty(amount) {
if (amount.counterparty === '') {
delete amount.counterparty;
}
}
function removeEmptyCounterpartyInBalanceChanges(balanceChanges) {
_.forEach(balanceChanges, (changes) => {
_.forEach(changes, removeEmptyCounterparty);
});
}
function removeEmptyCounterpartyInOrderbookChanges(orderbookChanges) {
_.forEach(orderbookChanges, (changes) => {
_.forEach(changes, (change) => {
_.forEach(change, removeEmptyCounterparty);
});
});
}
function parseOutcome(tx: Object): ?Object {
if (!tx.validated) {
return undefined;
@@ -20,6 +40,8 @@ function parseOutcome(tx: Object): ?Object {
const balanceChanges = transactionParser.parseBalanceChanges(tx.meta);
const orderbookChanges = transactionParser.parseOrderBookChanges(tx.meta);
removeEmptyCounterpartyInBalanceChanges(balanceChanges);
removeEmptyCounterpartyInOrderbookChanges(orderbookChanges);
return {
result: tx.meta.TransactionResult,

View File

@@ -47,14 +47,12 @@
],
"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59": [
{
"counterparty": "",
"currency": "XRP",
"value": "-1.101208"
}
],
"r9tGqzZgKxVFvzKFdUqXAqTzazWBUia8Qr": [
{
"counterparty": "",
"currency": "XRP",
"value": "1.101198"
},
@@ -70,7 +68,6 @@
{
"taker_pays": {
"currency": "XRP",
"counterparty": "",
"value": "-1.101198"
},
"taker_gets": {
@@ -136,14 +133,12 @@
],
"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59": [
{
"counterparty": "",
"currency": "XRP",
"value": "-1.101208"
}
],
"r9tGqzZgKxVFvzKFdUqXAqTzazWBUia8Qr": [
{
"counterparty": "",
"currency": "XRP",
"value": "1.101198"
},
@@ -159,7 +154,6 @@
{
"taker_pays": {
"currency": "XRP",
"counterparty": "",
"value": "-1.101198"
},
"taker_gets": {

View File

@@ -47,14 +47,12 @@
],
"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59": [
{
"counterparty": "",
"currency": "XRP",
"value": "-1.101208"
}
],
"r9tGqzZgKxVFvzKFdUqXAqTzazWBUia8Qr": [
{
"counterparty": "",
"currency": "XRP",
"value": "1.101198"
},
@@ -70,7 +68,6 @@
{
"taker_pays": {
"currency": "XRP",
"counterparty": "",
"value": "-1.101198"
},
"taker_gets": {