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); }