diff --git a/src/containers/Accounts/AccountHeader/index.jsx b/src/containers/Accounts/AccountHeader/index.jsx index 648a36ee2..c44e1b080 100644 --- a/src/containers/Accounts/AccountHeader/index.jsx +++ b/src/containers/Accounts/AccountHeader/index.jsx @@ -68,6 +68,7 @@ const AccountHeader = (props) => { ) } + const options = { ...CURRENCY_OPTIONS, currency: currencySelected } function renderPaymentChannels() { const { paychannels } = data return ( @@ -95,6 +96,8 @@ const AccountHeader = (props) => { function renderEscrows() { const { escrows } = data + const fIn = escrows && escrows.totalIn[currencySelected] + const fOut = escrows && escrows.totalOut[currencySelected] return ( escrows && (
@@ -102,15 +105,11 @@ const AccountHeader = (props) => {
diff --git a/src/containers/shared/components/Transaction/EscrowCreate/Description.tsx b/src/containers/shared/components/Transaction/EscrowCreate/Description.tsx index 04c6b8bde..51d56c272 100644 --- a/src/containers/shared/components/Transaction/EscrowCreate/Description.tsx +++ b/src/containers/shared/components/Transaction/EscrowCreate/Description.tsx @@ -55,11 +55,7 @@ const Description: TransactionDescriptionComponent = ( )}
{t('escrowed_amount')} - - {' '} - {normalizeAmount(data.tx.Amount, language)} - XRP - + {normalizeAmount(data.tx.Amount, language)}
{data.tx.CancelAfter && (
diff --git a/src/containers/shared/transactionUtils.ts b/src/containers/shared/transactionUtils.ts index 7bdf29e06..56903612d 100644 --- a/src/containers/shared/transactionUtils.ts +++ b/src/containers/shared/transactionUtils.ts @@ -250,7 +250,7 @@ export function normalizeAmount( const value = typeof amount === 'object' ? amount.value : Number(amount) / XRP_BASE const numberOption = { ...CURRENCY_OPTIONS, currency } - return localizeNumber(value, language, numberOption) + return `${localizeNumber(value, language, numberOption)} ${currency}` } export function findNode( diff --git a/src/containers/shared/utils.js b/src/containers/shared/utils.js index 12d6cd72d..0cd083dca 100644 --- a/src/containers/shared/utils.js +++ b/src/containers/shared/utils.js @@ -231,10 +231,14 @@ export function formatPrice(number, options = {}) { // Document: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat export const localizeDate = (date, lang = 'en-US', options = {}) => { // TODO: default config - if (!date) { + try { + if (!date) { + return null + } + return new Intl.DateTimeFormat(lang, options).format(date) + } catch { return null } - return new Intl.DateTimeFormat(lang, options).format(date) } /** diff --git a/src/rippled/lib/rippled.js b/src/rippled/lib/rippled.js index cfc832c6b..724ecbfa2 100644 --- a/src/rippled/lib/rippled.js +++ b/src/rippled/lib/rippled.js @@ -7,7 +7,7 @@ const formatEscrow = (d) => ({ id: d.index, account: d.Account, destination: d.Destination, - amount: d.Amount / XRP_BASE, + amount: d.Amount, condition: d.Condition, cancelAfter: d.CancelAfter ? convertRippleDate(d.CancelAfter) : undefined, finishAfter: d.FinishAfter ? convertRippleDate(d.FinishAfter) : undefined, @@ -146,22 +146,30 @@ const getAccountEscrows = ( return undefined } - const escrows = { in: [], out: [], total: 0, totalIn: 0, totalOut: 0 } + const escrows = { + in: [], + out: [], + total: 0, + totalIn: { XRP: 0 }, + totalOut: { XRP: 0 }, + } resp.account_objects.forEach((d) => { - const amount = Number(d.Amount) + const amount = + typeof d.Amount === 'object' + ? d.Amount.value + : Number(d.Amount) / XRP_BASE + const currency = typeof d.Amount === 'object' ? d.Amount.currency : 'XRP' escrows.total += amount + escrows.totalIn[currency] = 0 + escrows.totalOut[currency] = 0 if (account === d.Destination) { escrows.in.push(formatEscrow(d)) - escrows.totalIn += amount + escrows.totalIn[currency] = amount } else { escrows.out.push(formatEscrow(d)) - escrows.totalOut += amount + escrows.totalOut[currency] = amount } }) - - escrows.total /= XRP_BASE - escrows.totalIn /= XRP_BASE - escrows.totalOut /= XRP_BASE return escrows })