Skip to content

Commit

Permalink
bump
Browse files Browse the repository at this point in the history
  • Loading branch information
Majorfi committed Oct 17, 2023
1 parent d2d3ff3 commit 374a2b6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": [
Expand Down
9 changes: 4 additions & 5 deletions src/utils/handlers/handleInputChangeEventValue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 374a2b6

Please sign in to comment.