2021-05-12 16:52:17 +03:00
|
|
|
import JSBI from 'jsbi'
|
2020-07-10 19:42:24 +03:00
|
|
|
import { useMemo } from 'react'
|
2020-07-20 14:48:42 +03:00
|
|
|
import { NEVER_RELOAD, useSingleCallResult } from '../state/multicall/hooks'
|
2021-05-18 18:31:22 +03:00
|
|
|
import { useActiveWeb3React } from './web3'
|
2020-07-10 19:42:24 +03:00
|
|
|
import { useSocksController } from './useContract'
|
|
|
|
|
|
|
|
export default function useSocksBalance(): JSBI | undefined {
|
|
|
|
const { account } = useActiveWeb3React()
|
|
|
|
const socksContract = useSocksController()
|
|
|
|
|
2020-07-20 14:48:42 +03:00
|
|
|
const { result } = useSingleCallResult(socksContract, 'balanceOf', [account ?? undefined], NEVER_RELOAD)
|
2020-07-10 19:42:24 +03:00
|
|
|
const data = result?.[0]
|
|
|
|
return data ? JSBI.BigInt(data.toString()) : undefined
|
|
|
|
}
|
|
|
|
|
|
|
|
export function useHasSocks(): boolean | undefined {
|
|
|
|
const balance = useSocksBalance()
|
|
|
|
return useMemo(() => balance && JSBI.greaterThan(balance, JSBI.BigInt(0)), [balance])
|
|
|
|
}
|