From 6f7b535373be75c17023b8bfd46e303aa6e9e4ba Mon Sep 17 00:00:00 2001 From: "Felix C. Morency" <1102868+fmorency@users.noreply.github.com> Date: Tue, 26 Nov 2024 14:08:34 -0500 Subject: [PATCH] fix: coderabbit --- utils/maths.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/utils/maths.ts b/utils/maths.ts index 7dc09011..c0d319e6 100644 --- a/utils/maths.ts +++ b/utils/maths.ts @@ -32,8 +32,12 @@ export const shiftDigits = ( }; export const parseNumberToBigInt = (v: string, maxDigits: number = 6) => { - const amount = BigNumber(v); - const precision = BigNumber(`1e${maxDigits}`); + const amount = new BigNumber(v); + if (!amount.isFinite()) { + console.error(`Invalid input passed to parseNumberToBigInt: ${v}`); + return BigInt(0); + } + const precision = new BigNumber(10).pow(maxDigits); const b = amount.times(precision).toFixed(); return BigInt(b); };