Skip to content

Commit

Permalink
Merge pull request #154 from bnb-chain/cake/gasLimit1129
Browse files Browse the repository at this point in the history
fix: Hide input error message if not connect to wallet
  • Loading branch information
Halibao-Lala authored Dec 3, 2024
2 parents c9dad77 + e2e59c6 commit f98ef0d
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 f98ef0d

Please sign in to comment.