mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-12-06 17:27:59 +00:00
It is impossible to reliably compute the delivered amount from the metadata due to fixed precision. If the partial payment flag is not set and the transaction succeeded, the delivered amount should always be considered to be the amount specified in the transaction.
22 lines
448 B
JavaScript
22 lines
448 B
JavaScript
/* @flow */
|
|
'use strict';
|
|
const utils = require('../utils');
|
|
import type {Amount, RippledAmount} from '../../common/types.js';
|
|
|
|
|
|
function parseAmount(amount: RippledAmount): Amount {
|
|
if (typeof amount === 'string') {
|
|
return {
|
|
currency: 'XRP',
|
|
value: utils.common.dropsToXrp(amount)
|
|
};
|
|
}
|
|
return {
|
|
currency: amount.currency,
|
|
value: amount.value,
|
|
counterparty: amount.issuer
|
|
};
|
|
}
|
|
|
|
module.exports = parseAmount;
|