2021-07-07 00:08:40 +03:00
|
|
|
import { Token } from '@uniswap/sdk-core'
|
2021-09-22 02:21:28 +03:00
|
|
|
import { SOCKS_CONTROLLER_ADDRESSES } from 'constants/addresses'
|
2021-07-07 00:08:40 +03:00
|
|
|
import { SupportedChainId } from 'constants/chains'
|
2021-09-22 02:21:28 +03:00
|
|
|
import { useMemo } from 'react'
|
|
|
|
import { useTokenBalance } from 'state/wallet/hooks'
|
|
|
|
|
|
|
|
import { useActiveWeb3React } from './web3'
|
2020-07-10 19:42:24 +03:00
|
|
|
|
2021-07-07 00:08:40 +03:00
|
|
|
// technically a 721, not an ERC20, but suffices for our purposes
|
|
|
|
const SOCKS = new Token(SupportedChainId.MAINNET, SOCKS_CONTROLLER_ADDRESSES[SupportedChainId.MAINNET], 0)
|
2020-07-10 19:42:24 +03:00
|
|
|
|
|
|
|
export function useHasSocks(): boolean | undefined {
|
2021-07-07 00:08:40 +03:00
|
|
|
const { account, chainId } = useActiveWeb3React()
|
|
|
|
|
|
|
|
const balance = useTokenBalance(account ?? undefined, chainId === SupportedChainId.MAINNET ? SOCKS : undefined)
|
|
|
|
|
|
|
|
return useMemo(() => Boolean(balance?.greaterThan(0)), [balance])
|
2020-07-10 19:42:24 +03:00
|
|
|
}
|