Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Hide input error message if not connect to wallet #154

Merged
merged 1 commit into from
Dec 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading