Skip to content

Commit

Permalink
fix withdraw-form
Browse files Browse the repository at this point in the history
  • Loading branch information
Yehor Podporinov authored and Yehor Podporinov committed Jan 24, 2024
1 parent 108d988 commit 43a6eb1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
6 changes: 2 additions & 4 deletions src/forms/WithdrawForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -63,9 +63,7 @@ const form = reactive({
amount: '' as string,
})
const availableEther = computed<string>(() =>
formatEther(props.availableAmount),
)
const availableEther = computed<string>(() => toEther(props.availableAmount))
const { getFieldErrorMessage, isFieldsValid, isFormValid, touchField } =
useFormValidation(form, {
Expand Down
10 changes: 5 additions & 5 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -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 }

0 comments on commit 43a6eb1

Please sign in to comment.