mirror of
https://github.com/XRPLF/xrpl-dev-portal.git
synced 2025-11-24 13:45:49 +00:00
- Fixed partial payment exploit
- added custom token to displayable amount
This commit is contained in:
@@ -6,9 +6,22 @@ const prepareTxData = (transactions) => {
|
||||
type: transaction.tx.TransactionType,
|
||||
from: transaction.tx.Account,
|
||||
to: transaction.tx.Destination,
|
||||
value: xrpl.dropsToXrp(transaction.tx.Amount),
|
||||
value: getDisplayableAmount(transaction.meta.delivered_amount),
|
||||
hash: transaction.tx.hash
|
||||
}))
|
||||
}
|
||||
|
||||
const getDisplayableAmount = (rawAmount) => {
|
||||
if (rawAmount === 'unavailable') {
|
||||
// Special case for pre-2014 partial payments.
|
||||
return rawAmount
|
||||
} else if (typeof rawAmount === 'string') {
|
||||
// It's an XRP amount in drops. Convert to decimal.
|
||||
return xrpl.dropsToXrp(rawAmount) + ' XRP'
|
||||
} else {
|
||||
//It's a token (IOU) amount.
|
||||
return rawAmount.value + ' ' + rawAmount.currency
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { prepareTxData }
|
||||
|
||||
Reference in New Issue
Block a user