assembly/composables/useParsing.ts

17 lines
372 B
TypeScript
Raw Normal View History

2021-07-26 22:19:20 +00:00
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 };
}