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

@@ -9,7 +9,7 @@ function xrpToDrops(xrp) {
return (new BigNumber(xrp)).times(1000000.0).floor().toString();
}
function convertAmount(amount) {
function toRippledAmount(amount) {
if (amount.currency === 'XRP') {
return xrpToDrops(amount.value);
}
@@ -20,8 +20,20 @@ function convertAmount(amount) {
};
}
function wrapCatch(asyncFunction: () => void): () => void {
return function() {
try {
asyncFunction.apply(this, arguments);
} catch (error) {
const callback = arguments[arguments.length - 1];
callback(error);
}
};
}
module.exports = {
dropsToXrp: dropsToXrp,
xrpToDrops: xrpToDrops,
convertAmount: convertAmount
dropsToXrp,
xrpToDrops,
toRippledAmount,
wrapCatch
};