mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-22 01:47:00 +01:00
Don't call "toPrecisionWithoutTrailingZeros" if a destination value is not a number (#20525)
This commit is contained in:
parent
702ee233e7
commit
8ca0b762ad
@ -401,6 +401,12 @@ describe('Swaps Util', () => {
|
||||
'39.6493201125',
|
||||
);
|
||||
});
|
||||
|
||||
it('gets swaps value for display when the value contains three dots', () => {
|
||||
expect(formatSwapsValueForDisplay('33680099000000000000...')).toBe(
|
||||
'33680099000000000000...',
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('getSwapsTokensReceivedFromTxMeta', () => {
|
||||
|
@ -545,8 +545,18 @@ export function quotesToRenderableData({
|
||||
});
|
||||
}
|
||||
|
||||
export function formatSwapsValueForDisplay(destinationAmount: string): string {
|
||||
let amountToDisplay = toPrecisionWithoutTrailingZeros(destinationAmount, 12);
|
||||
export function formatSwapsValueForDisplay(
|
||||
destinationAmount: string | BigNumber,
|
||||
): string {
|
||||
let amountToDisplay;
|
||||
if (
|
||||
typeof destinationAmount === 'string' &&
|
||||
destinationAmount.includes('...')
|
||||
) {
|
||||
amountToDisplay = destinationAmount;
|
||||
} else {
|
||||
amountToDisplay = toPrecisionWithoutTrailingZeros(destinationAmount, 12);
|
||||
}
|
||||
if (amountToDisplay.match(/e[+-]/u)) {
|
||||
amountToDisplay = new BigNumber(amountToDisplay).toFixed();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user