assembly/composables/useParsing.ts
Georges KABBOUCHI a54be3569c wip
2021-07-27 01:19:20 +03:00

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