Skip to content

Commit

Permalink
fix: Hide input error message if not connect to wallet
Browse files Browse the repository at this point in the history
  • Loading branch information
Halibao-Lala committed Dec 3, 2024
1 parent c9dad77 commit e2e59c6
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ import { formatNumber } from '@/core/utils/number';
import { useAppSelector } from '@/modules/store/StoreProvider';
import { useSolanaBalance } from '@/modules/wallet/hooks/useSolanaBalance';
import { MIN_SOL_TO_ENABLED_TX } from '@/core/constants';
import { useIsWalletCompatible } from '@/modules/wallet/hooks/useIsWalletCompatible';

export const useInputValidation = () => {
const { data } = useSolanaBalance();
const isWalletCompatible = useIsWalletCompatible();
const solBalance = Number(data?.formatted);

const fromChain = useAppSelector((state) => state.transfer.fromChain);
const validateInput = useCallback(
({
Expand Down Expand Up @@ -59,15 +60,15 @@ export const useInputValidation = () => {
} else {
return { text: `${formatNumber(balance)}`, isError: false };
}
} else {
} else if (isWalletCompatible) {
return { isError: true, text: 'You have insufficient balance' };
}
} catch (e: any) {
// eslint-disable-next-line no-console
console.log(e);
}
},
[fromChain?.chainType, solBalance],
[fromChain?.chainType, solBalance, isWalletCompatible],
);

return {
Expand Down

0 comments on commit e2e59c6

Please sign in to comment.