diff --git a/src/forms/WithdrawForm.vue b/src/forms/WithdrawForm.vue index 5fb5819..7128d20 100644 --- a/src/forms/WithdrawForm.vue +++ b/src/forms/WithdrawForm.vue @@ -40,7 +40,7 @@ import { AppButton } from '@/common' import { useContract, useFormValidation } from '@/composables' import { InputField } from '@/fields' import { bus, BUS_EVENTS, ErrorHandler } from '@/helpers' -import { BigNumber, formatEther, parseUnits } from '@/utils' +import { BigNumber, parseUnits, toEther } from '@/utils' import { ether, maxEther, required } from '@/validators' import { config } from '@config' import { computed, reactive, ref } from 'vue' @@ -63,9 +63,7 @@ const form = reactive({ amount: '' as string, }) -const availableEther = computed(() => - formatEther(props.availableAmount), -) +const availableEther = computed(() => toEther(props.availableAmount)) const { getFieldErrorMessage, isFieldsValid, isFormValid, touchField } = useFormValidation(form, { diff --git a/src/utils/index.ts b/src/utils/index.ts index 4de4cb8..db13caf 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -1,14 +1,14 @@ import { utils, BigNumber } from 'ethers' import { Time } from '@distributedlab/tools' -const formatEther: typeof utils.formatEther = (...params) => { - const str = utils.formatEther(...params) +const { parseUnits, formatEther: toEther } = utils + +const formatEther: typeof toEther = (...params) => { + const str = toEther(...params) const indexOfDot = str.indexOf('.') const sliced = indexOfDot !== -1 ? str.slice(0, indexOfDot + 5) : str return Number(Number(sliced).toFixed(4)).toString() } -const { parseUnits } = utils - -export { formatEther, parseUnits, Time, BigNumber } +export { formatEther, parseUnits, toEther, Time, BigNumber }