From dad87b82b13e7fc4834b229678a475c5d2597534 Mon Sep 17 00:00:00 2001 From: Ryan Noble Date: Fri, 13 Dec 2024 10:26:17 +0100 Subject: [PATCH] Revert "feat: added balance updated check" This reverts commit 3dfd732621526d25b57609e3db170ca31011e0a3. --- src/features/swap/SwapForm.tsx | 4 ++-- src/features/swap/useFormValidator.ts | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/features/swap/SwapForm.tsx b/src/features/swap/SwapForm.tsx index cde9e59..3da54fd 100644 --- a/src/features/swap/SwapForm.tsx +++ b/src/features/swap/SwapForm.tsx @@ -60,7 +60,7 @@ export function SwapFormCard() { } function SwapForm() { - const { balances, lastUpdated } = useAppSelector((s) => s.account) + const balances = useAppSelector((s) => s.account.balances) const { showSlippage } = useAppSelector((s) => s.swap) const dispatch = useAppDispatch() @@ -68,7 +68,7 @@ function SwapForm() { dispatch(setFormValues(values)) dispatch(setConfirmView(true)) // Switch to confirm view } - const validateForm = useFormValidator(balances, lastUpdated) + const validateForm = useFormValidator(balances) const storedFormValues = useAppSelector((s) => s.swap.formValues) // Get stored form values const initialFormValues = storedFormValues || initialValues // Use stored values if they exist diff --git a/src/features/swap/useFormValidator.ts b/src/features/swap/useFormValidator.ts index 4f26f1a..410731f 100644 --- a/src/features/swap/useFormValidator.ts +++ b/src/features/swap/useFormValidator.ts @@ -9,12 +9,11 @@ import { areAmountsNearlyEqual, parseAmount, toWei } from 'src/utils/amount' import { logger } from 'src/utils/logger' import { useChainId } from 'wagmi' -export function useFormValidator(balances: AccountBalances, lastUpdated: number | null) { +export function useFormValidator(balances: AccountBalances) { const chainId = useChainId() return useCallback( (values?: SwapFormValues): Promise> => { return (async () => { - if (!lastUpdated) return { fromTokenId: 'Balance still loading' } if (!values || !values.amount) return { amount: 'Amount Required' } const parsedAmount = parseAmount(values.amount) if (!parsedAmount) return { amount: 'Amount is Invalid' } @@ -34,7 +33,7 @@ export function useFormValidator(balances: AccountBalances, lastUpdated: number return {} }) }, - [balances, chainId, lastUpdated] + [balances, chainId] ) }