Skip to content

Commit fb7e0c3

Browse files
committed
fix linter errors
1 parent eb7dbe6 commit fb7e0c3

File tree

4 files changed

+33
-29
lines changed

4 files changed

+33
-29
lines changed

src/containers/Vault/VaultHeader/index.tsx

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,7 @@ import { MPT_ROUTE } from '../../App/routes'
1010
import SocketContext from '../../shared/SocketContext'
1111
import { getMPTIssuance } from '../../../rippled/lib/rippled'
1212
import { parseVaultWebsite } from '../utils'
13-
import {
14-
shortenVaultID,
15-
shortenAccount,
16-
} from '../../shared/utils'
13+
import { shortenVaultID, shortenAccount } from '../../shared/utils'
1714
import './styles.scss'
1815
import { useAnalytics } from '../../shared/analytics'
1916
import { parseAmount } from '../../shared/NumberFormattingUtils'
@@ -63,7 +60,11 @@ export const VaultHeader = ({ data, vaultId, displayCurrency }: Props) => {
6360
const { t } = useTranslation()
6461
const { trackException } = useAnalytics()
6562
const rippledSocket = useContext(SocketContext)
66-
const { rate: tokenToUsdRate } = useTokenToUSDRate(data.Asset)
63+
const { rate: tokenToUsdRate } = useTokenToUSDRate(
64+
data.Asset?.currency
65+
? { currency: data.Asset.currency, issuer: data.Asset.issuer }
66+
: undefined,
67+
)
6768

6869
const {
6970
Owner: owner,
@@ -271,7 +272,11 @@ export const VaultHeader = ({ data, vaultId, displayCurrency }: Props) => {
271272
}
272273
const amount = convertedAmount ?? assetsTotal
273274
if (amount === undefined) return '--'
274-
if (['0', '0.00', '0.0000'].includes(parseAmount(amount ?? '0', 2)))
275+
if (
276+
['0', '0.00', '0.0000'].includes(
277+
parseAmount(amount ?? '0', 2),
278+
)
279+
)
275280
return '--'
276281
// Note: As per the NumberFormat policy, prices in the range of [10_000, 1M] do not display decimal values
277282
// Very large prices (greater than 1M must have two decimal places)
@@ -284,14 +289,12 @@ export const VaultHeader = ({ data, vaultId, displayCurrency }: Props) => {
284289
<TokenTableRow
285290
label={t('max_total_supply')}
286291
value={(() => {
287-
if (assetsMaximum === undefined)
288-
return t('no_limit')
292+
if (assetsMaximum === undefined) return t('no_limit')
289293

290294
const parsedAmt = parseAmount(assetsMaximum, 2)
291-
if (['0', '0.00', '0.0000'].includes(parsedAmt))
292-
return '--'
295+
if (['0', '0.00', '0.0000'].includes(parsedAmt)) return '--'
293296

294-
return parsedAmt + ' ' + getAssetCurrency(asset)
297+
return `${parsedAmt} ${getAssetCurrency(asset)}`
295298
})()}
296299
/>
297300
<TokenTableRow
@@ -302,18 +305,16 @@ export const VaultHeader = ({ data, vaultId, displayCurrency }: Props) => {
302305
label={t('available_to_borrow')}
303306
value={(() => {
304307
const parsedAmt = parseAmount(assetsAvailable ?? '0', 2)
305-
if (['0', '0.00', '0.0000'].includes(parsedAmt))
306-
return '--'
307-
return parsedAmt + ' ' + getAssetCurrency(asset)
308+
if (['0', '0.00', '0.0000'].includes(parsedAmt)) return '--'
309+
return `${parsedAmt} ${getAssetCurrency(asset)}`
308310
})()}
309311
/>
310312
<TokenTableRow
311313
label={t('unrealized_loss')}
312314
value={(() => {
313315
const parsedAmt = parseAmount(lossUnrealized ?? '0', 2)
314-
if (['0', '0.00', '0.0000'].includes(parsedAmt))
315-
return '--'
316-
return parsedAmt + ' ' + getAssetCurrency(asset)
316+
if (['0', '0.00', '0.0000'].includes(parsedAmt)) return '--'
317+
return `${parsedAmt} ${getAssetCurrency(asset)}`
317318
})()}
318319
/>
319320
</tbody>

src/containers/Vault/VaultHeader/test/VaultHeader.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ describe('VaultHeader Component', () => {
402402
)
403403

404404
// Should be a link to the MPT page with exact truncated text
405-
const mptLink = screen.getByRole('link', { name: 'MPT (' + mptId + ')' })
405+
const mptLink = screen.getByRole('link', { name: `MPT (${mptId})` })
406406
expect(mptLink.getAttribute('href')).toBe(`/mpt/${mptId}`)
407407
})
408408

src/containers/Vault/VaultLoans/BrokerDetails.tsx

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@ import { formatRate, LSF_LOAN_DEFAULT } from './utils'
55
import { BrokerLoansTable } from './BrokerLoansTable'
66
import WarningIcon from '../../shared/images/warning.svg'
77
import { parseAmount } from '../../shared/NumberFormattingUtils'
8-
import {
9-
shortenMPTID,
10-
getCurrencySymbol,
11-
} from '../../shared/utils'
8+
import { shortenMPTID, getCurrencySymbol } from '../../shared/utils'
129

1310
// TODO: Use types from xrpl.js instead of hand-writing it.
1411
interface LoanBrokerData {
@@ -62,16 +59,24 @@ export const BrokerDetails = ({
6259
loan.TotalValueOutstanding > 0 && (loan.Flags ?? 0) & LSF_LOAN_DEFAULT,
6360
)
6461

65-
const formatBrokerAmount = (amount: string | undefined, asset: AssetInfo | undefined): string => {
62+
const formatBrokerAmount = (
63+
amount: string | undefined,
64+
inputAsset: AssetInfo | undefined,
65+
): string => {
6666
const convertedAmount = convertToDisplayCurrency(amount)
6767
if (convertedAmount === undefined && displayCurrency === 'usd') {
6868
return '--'
6969
}
7070

7171
const finalDisplayAmount = convertedAmount ?? amount
72-
if(finalDisplayAmount !== undefined)
73-
return `${parseAmount(finalDisplayAmount, 2)}` + ' ' + (getCurrencySymbol(asset?.currency) ??
74-
`MPT (${shortenMPTID(asset?.mpt_issuance_id)})`)
72+
if (finalDisplayAmount !== undefined)
73+
return (
74+
`${parseAmount(finalDisplayAmount, 2)}` +
75+
` ${
76+
getCurrencySymbol(inputAsset?.currency) ??
77+
`MPT (${shortenMPTID(inputAsset?.mpt_issuance_id)})`
78+
}`
79+
)
7580
return '--'
7681
}
7782

src/containers/Vault/VaultLoans/test/VaultLoans.test.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -728,9 +728,7 @@ describe('VaultLoans Component', () => {
728728

729729
await waitFor(() => {
730730
expect(screen.getByText('Loan Broker ID')).toBeInTheDocument()
731-
expect(
732-
screen.getByText(brokerId),
733-
).toBeInTheDocument()
731+
expect(screen.getByText(brokerId)).toBeInTheDocument()
734732
})
735733
})
736734

0 commit comments

Comments
 (0)