import { Contract } from '@ethersproject/contracts' import { useMemo } from 'react' import { getBep20Contract, getContract } from '../utils/contractHelpers' import useActiveWeb3React from 'dapp-next/src/hooks/useActiveWeb3React' // ==================== Token ==================== export function useTokenContract(tokenAddress?: string): Contract | null { const { account, library } = useActiveWeb3React() return useMemo( () => getBep20Contract(tokenAddress, account ? library.getSigner() : library), [library, account, tokenAddress], ) } // ==================== Contract ==================== export const useContract = (abi: any, address: string) => { const { account, library } = useActiveWeb3React() return useMemo( () => getContract(abi, address, account ? library.getSigner() : library), [abi, address, account, library], ) }