Skip to content

Commit

Permalink
Merge pull request #1559 from bancorprotocol/fix/maximumfraction
Browse files Browse the repository at this point in the history
default maximumFractionDigits to 3
  • Loading branch information
GrandSchtroumpf authored Oct 30, 2024
2 parents 37cac15 + 7738825 commit 03a4fc8
Show file tree
Hide file tree
Showing 14 changed files with 18 additions and 1 deletion.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 18 additions & 1 deletion src/utils/helpers/number.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { FiatSymbol } from 'utils/carbonApi';
import { SafeDecimal } from 'libs/safedecimal';
import { Token } from 'libs/tokens';
import { captureException, setContext } from '@sentry/react';

export type NumberLike = number | string | SafeDecimal;

Expand Down Expand Up @@ -162,7 +163,23 @@ export function prettifyNumber(
} else {
intlOptions.maximumSignificantDigits = 5;
}
const formatter = new Intl.NumberFormat(locale, intlOptions);
let formatter: Intl.NumberFormat;
try {
formatter = new Intl.NumberFormat(locale, intlOptions);
} catch (e) {
const ctx = {
value: value.toString(),
intlOptions,
locale: locale ?? navigator.language,
};
setContext('prettifyNumber', ctx);
console.error('[ERROR] prettifyNumber', ctx);
captureException(e);
if (intlOptions.minimumFractionDigits) {
intlOptions.maximumFractionDigits = intlOptions.minimumFractionDigits + 1;
}
formatter = new Intl.NumberFormat(locale, intlOptions);
}

if (options.highPrecision) {
return highPrecision(num, formatter, options.decimals);
Expand Down

0 comments on commit 03a4fc8

Please sign in to comment.