Move ripple-rest/api into src/api, exposing RippleAPI

This commit is contained in:
Chris Clark
2015-05-22 13:57:41 -07:00
parent 16e3541a10
commit 278331cc4a
100 changed files with 5653 additions and 72 deletions

27
src/api/common/utils.js Normal file
View File

@@ -0,0 +1,27 @@
'use strict';
const BigNumber = require('bignumber.js');
function dropsToXrp(drops) {
return (new BigNumber(drops)).dividedBy(1000000.0).toString();
}
function xrpToDrops(xrp) {
return (new BigNumber(xrp)).times(1000000.0).floor().toString();
}
function convertAmount(amount) {
if (amount.currency === 'XRP') {
return xrpToDrops(amount.value);
}
return {
currency: amount.currency,
issuer: amount.counterparty ? amount.counterparty : amount.issuer,
value: amount.value
};
}
module.exports = {
dropsToXrp: dropsToXrp,
xrpToDrops: xrpToDrops,
convertAmount: convertAmount
};