Rewrite transaction parser and add unit test for getTransaction

This commit is contained in:
Chris Clark
2015-06-09 17:59:02 -07:00
parent df0cff969c
commit 1b936d2aa2
34 changed files with 570 additions and 707 deletions

View File

@@ -43,30 +43,6 @@ function parseLedger(ledger) {
return 'validated';
}
function parseCurrencyAmount(rippledAmount, useIssuer) {
const amount = {};
if (typeof rippledAmount === 'string') {
amount.currency = 'XRP';
amount.value = common.dropsToXrp(rippledAmount);
if (useIssuer) {
amount.issuer = '';
} else {
amount.counterparty = '';
}
} else {
amount.currency = rippledAmount.currency;
amount.value = rippledAmount.value;
if (useIssuer) {
amount.issuer = rippledAmount.issuer;
} else {
amount.counterparty = rippledAmount.issuer;
}
}
return amount;
}
function signum(num) {
return (num === 0) ? 0 : (num > 0 ? 1 : -1);
}
@@ -121,11 +97,11 @@ function attachDate(api, baseTransactions, callback) {
module.exports = {
parseLedger: parseLedger,
parseCurrencyAmount: parseCurrencyAmount,
compareTransactions: compareTransactions,
renameCounterpartyToIssuer: renameCounterpartyToIssuer,
renameCounterpartyToIssuerInOrder: renameCounterpartyToIssuerInOrder,
attachDate: attachDate,
wrapCatch: common.wrapCatch,
common: common
};