text: import { useEffect, useState } from "react";
  import { useMoralis, useMoralisWeb3Api } from "react-moralis";
  import { useMoralisDapp } from "providers/MoralisDappProvider/MoralisDappProvider";
  
  export const useERC20Balance = (params) => {
    const { account } = useMoralisWeb3Api();
    const { isInitialized } = useMoralis();
    const { walletAddress, chainId } = useMoralisDapp();
  
    const [assets, setAssets] = useState();
  
    useEffect(() => {
      if (isInitialized) {
        fetchERC20Balance()
          .then((balance) => setAssets(balance))
          .catch((e) => alert(e.message));
      }
      // eslint-disable-next-line react-hooks/exhaustive-deps
    }, [isInitialized, chainId, walletAddress]);
  
    const fetchERC20Balance = async () => {
      return await account
        .getTokenBalances({ address: walletAddress, chain: params?.chain || chainId })
        .then((result) => result)
        .catch((e) => alert(e.message));
    };
  
    return { fetchERC20Balance, assets };
  };
  