diff --git a/tauri-wallet/src/routes/send/SendConfirmation.tsx b/tauri-wallet/src/routes/send/SendConfirmation.tsx index 8d3b162096..4b19369641 100644 --- a/tauri-wallet/src/routes/send/SendConfirmation.tsx +++ b/tauri-wallet/src/routes/send/SendConfirmation.tsx @@ -3,14 +3,14 @@ import { Card, CircularProgress, Theme, Typography } from '@material-ui/core' import { CheckCircleOutline } from '@material-ui/icons' import { useTheme } from '@material-ui/styles' import { SendError } from './SendError' -import { TFormData } from './SendWizard' +import { TauriTxResult } from '../../types/rust/tauritxresult' export const SendConfirmation = ({ data, error, isLoading, }: { - data?: Pick + data?: TauriTxResult['details'] error?: string isLoading: boolean }) => { @@ -60,7 +60,7 @@ export const SendConfirmation = ({
- {data.to} + {data.to_address}
@@ -70,7 +70,7 @@ export const SendConfirmation = ({
- {data.amount + ' punks'} + {data.amount.amount + ' punks'}
diff --git a/tauri-wallet/src/routes/send/SendForm.tsx b/tauri-wallet/src/routes/send/SendForm.tsx index 1f9c6b39c9..de4461bac3 100644 --- a/tauri-wallet/src/routes/send/SendForm.tsx +++ b/tauri-wallet/src/routes/send/SendForm.tsx @@ -33,8 +33,8 @@ export const SendForm = () => { label="To" fullWidth autoFocus - error={!!errors.recipient} - helperText={errors.recipient?.message} + error={!!errors.to} + helperText={errors.to?.message} /> diff --git a/tauri-wallet/src/routes/send/SendWizard.tsx b/tauri-wallet/src/routes/send/SendWizard.tsx index ed84c08f73..3e1b7429cb 100644 --- a/tauri-wallet/src/routes/send/SendWizard.tsx +++ b/tauri-wallet/src/routes/send/SendWizard.tsx @@ -6,10 +6,10 @@ import { useTheme } from '@material-ui/styles' import { SendForm } from './SendForm' import { SendReview } from './SendReview' import { SendConfirmation } from './SendConfirmation' -import { SendError } from './SendError' import { ClientContext } from '../../context/main' import { validationSchema } from './validationSchema' import { invoke } from '@tauri-apps/api' +import { TauriTxResult } from '../../types/rust/tauritxresult' const defaultValues = { amount: '', @@ -28,8 +28,7 @@ export const SendWizard = () => { const [activeStep, setActiveStep] = useState(0) const [isLoading, setIsLoading] = useState(false) const [requestError, setRequestError] = useState() - const [confirmedData, setConfirmedData] = - useState<{ amount: string; recipient: string }>() + const [confirmedData, setConfirmedData] = useState() const steps = ['Enter address', 'Review and send', 'Await confirmation'] @@ -50,6 +49,9 @@ export const SendWizard = () => { const handleFinish = () => { methods.reset() + setIsLoading(false) + setRequestError(undefined) + setConfirmedData(undefined) setActiveStep(0) } @@ -62,13 +64,10 @@ export const SendWizard = () => { amount: { denom: 'punk', amount: formState.amount }, memo: formState.memo, }) - .then((res) => { - console.log(res) + .then((res: any) => { + const { details } = res as TauriTxResult setActiveStep((s) => s + 1) - setConfirmedData({ - amount: formState.amount, - recipient: formState.to, - }) + setConfirmedData(details) setIsLoading(false) }) diff --git a/tauri-wallet/src/routes/send/validationSchema.ts b/tauri-wallet/src/routes/send/validationSchema.ts index b734db9d24..15008ff78e 100644 --- a/tauri-wallet/src/routes/send/validationSchema.ts +++ b/tauri-wallet/src/routes/send/validationSchema.ts @@ -1,8 +1,8 @@ import * as Yup from 'yup' -import { validateAmount, validateKey } from '../../utils' +import { validateAmount } from '../../utils' export const validationSchema = Yup.object().shape({ - to: Yup.string().required(), + to: Yup.string().strict().trim('Cannot have leading space').required(), amount: Yup.string() .required() .test('valid-amount', 'A valid amount is required', (amount) => { diff --git a/tauri-wallet/src/utils/index.ts b/tauri-wallet/src/utils/index.ts index d4faac1a60..41c9130542 100644 --- a/tauri-wallet/src/utils/index.ts +++ b/tauri-wallet/src/utils/index.ts @@ -41,12 +41,12 @@ export const validateAmount = async ( } export const basicRawCoinValueValidation = (rawAmount: string): boolean => { - const amountFloat = parseFloat(rawAmount) - - if (isNaN(amountFloat)) { + if (!Number(rawAmount)) { return false } + const amountFloat = parseFloat(rawAmount) + // it cannot have more than 6 decimal places if (amountFloat !== parseInt(amountFloat.toFixed(6))) { return false