form updates
This commit is contained in:
@@ -6,6 +6,6 @@ export const validationSchema = Yup.object().shape({
|
||||
amount: Yup.string()
|
||||
.required()
|
||||
.test('valid-amount', 'A valid amount is required', (amount) => {
|
||||
return validateAmount(amount || '0', '1')
|
||||
return validateAmount(amount || '0', '0')
|
||||
}),
|
||||
})
|
||||
|
||||
@@ -20,15 +20,16 @@ export const validateAmount = async (
|
||||
minimum: string
|
||||
): Promise<boolean> => {
|
||||
// tests basic coin value requirements, like no more than 6 decimal places, value lower than total supply, etc
|
||||
if (!basicRawCoinValueValidation(amount)) {
|
||||
return false
|
||||
}
|
||||
|
||||
try {
|
||||
const minorValueStr: Coin = await invoke('major_to_minor', {
|
||||
amount,
|
||||
})
|
||||
|
||||
if (!basicRawCoinValueValidation(minorValueStr.amount)) {
|
||||
return false
|
||||
}
|
||||
|
||||
const minorValue = parseInt(minorValueStr.amount)
|
||||
|
||||
return minorValue >= parseInt(minimum)
|
||||
@@ -44,7 +45,7 @@ export const basicRawCoinValueValidation = (rawAmount: string): boolean => {
|
||||
if (!Number(rawAmount)) {
|
||||
return false
|
||||
}
|
||||
|
||||
debugger
|
||||
const amountFloat = parseFloat(rawAmount)
|
||||
|
||||
// it cannot have more than 6 decimal places
|
||||
|
||||
Reference in New Issue
Block a user