From 374a2b611303ce4b48bca693d7c78d82deae1f73 Mon Sep 17 00:00:00 2001 From: Majorfi Date: Tue, 17 Oct 2023 14:39:22 +0200 Subject: [PATCH] bump --- package.json | 2 +- src/utils/handlers/handleInputChangeEventValue.ts | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 450713ac..7f6f6532 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@yearn-finance/web-lib", - "version": "3.0.56", + "version": "3.0.57", "main": "./dist/index.js", "types": "./dist/index.d.js", "files": [ diff --git a/src/utils/handlers/handleInputChangeEventValue.ts b/src/utils/handlers/handleInputChangeEventValue.ts index df256dda..5e031502 100644 --- a/src/utils/handlers/handleInputChangeEventValue.ts +++ b/src/utils/handlers/handleInputChangeEventValue.ts @@ -7,13 +7,12 @@ export function handleInputChangeEventValue(value: string, decimals?: number): T return {raw: 0n, normalized: ''}; } - let amount = value.replace(/,/g, '.').replace(/[^0-9.]/g, ''); - const amountParts = amount.split('.'); - - if (amountParts.length > 2) { - throw new Error(`Invalid amount: ${amount}`); + let amount = value.replace(/,/g, '.').replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1'); + if (amount.startsWith('.')) { + amount = '0' + amount; } + const amountParts = amount.split('.'); if (amountParts.length === 2) { amount = amountParts[0] + '.' + amountParts[1].slice(0, decimals); }