From 9452bbdbeb403a5c4873cafac0de996c1c2bf979 Mon Sep 17 00:00:00 2001 From: zzq0826 <770166635@qq.com> Date: Fri, 17 May 2024 08:29:01 +0800 Subject: [PATCH 1/2] =?UTF-8?q?Auto=20squash=20#1057=20=E2=80=89[bot]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2e4fe6255..b2391cec0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "scroll.io", - "version": "5.0.90", + "version": "5.0.91", "private": false, "license": "MIT", "scripts": { From 93233b449b0bd1275e17b7d50244080fb65176d6 Mon Sep 17 00:00:00 2001 From: Yvaine Date: Tue, 21 May 2024 14:32:23 +0800 Subject: [PATCH 2/2] fix: consider thousandSeparated (#1058) --- src/utils/format.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/utils/format.ts b/src/utils/format.ts index 2c82a3670..2fabd90a0 100644 --- a/src/utils/format.ts +++ b/src/utils/format.ts @@ -17,7 +17,7 @@ export const commafy = (value: string | number | undefined, decimals: number = 2 try { return numbro(value).format({ thousandSeparated: true, - optionalMantissa: false, + optionalMantissa: true, mantissa: decimals, }) } catch (err) { @@ -67,7 +67,8 @@ export const toPrecision = (amount, precise = 8) => { } const withPrecision = commafy(amount, significantDecimals) // Remove trailing zeros after decimal point - return parseFloat(withPrecision).toString() + const withoutTrailingZero = withPrecision.replace(/(\.\d*?)0+$/, "$1").replace(/(\.\d+?)0+$/, "$10") + return withoutTrailingZero } export function sanitizeNumericalString(numStr: string) {