mirror of
https://github.com/Instadapp/assembly.git
synced 2024-07-29 22:37:06 +00:00
17 lines
372 B
TypeScript
17 lines
372 B
TypeScript
|
import { useBigNumber } from "./useBigNumber";
|
||
|
|
||
|
export function useParsing() {
|
||
|
const { toBN } = useBigNumber();
|
||
|
|
||
|
function parseSafeFloat(value) {
|
||
|
if (value === null) return "0";
|
||
|
if (value === undefined) return "0";
|
||
|
|
||
|
const normalizedAmount = String(value).replace(",", ".");
|
||
|
|
||
|
return toBN(normalizedAmount).toFixed();
|
||
|
}
|
||
|
|
||
|
return { parseSafeFloat };
|
||
|
}
|