mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-24 22:25:48 +00:00
Move ripple-rest/api into src/api, exposing RippleAPI
This commit is contained in:
27
src/api/common/utils.js
Normal file
27
src/api/common/utils.js
Normal 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
|
||||
};
|
||||
Reference in New Issue
Block a user