lib/hooks/useUsersDripData.js
// can still claim from the drips. It only needs the 3_1_0 subgraph
can still claim from the drips. It only needs the 3_1_0 subgraph
can still claim from the drips . It only needs the 3_1_0 subgraph
function useUsersDripData() {
  const { address: usersAddress } = useOnboard()
  const chainId = usePoolTokenChainId()
  const readProvider = useReadProvider(chainId)
  const { contractAddresses } = useContractAddresses(chainId)
  const { data: graphDripData, error } = usePoolDripsQuery()
  if (error) {
    console.error(error)
  }
  let pairs = []
  let dripTokens = []
  let comptrollerAddress
  if (graphDripData?.balanceDrips) {
    const balanceDripPairs = graphDripData?.balanceDrips.map((drip) => [
      drip.sourceAddress,
      drip.measureToken
    ])
    const volumeDripPairs = graphDripData?.volumeDrips.map((drip) => [
      drip.sourceAddress,
      drip.measureToken
    ])
    pairs = uniqWith(balanceDripPairs?.concat(volumeDripPairs), isEqual)
    const balanceDripTokens = graphDripData?.balanceDrips.map((drip) => drip.dripToken)
    const volumeDripTokens = graphDripData?.volumeDrips.map((drip) => drip.dripToken)
    dripTokens = uniqWith(balanceDripTokens?.concat(volumeDripTokens), isEqual)
    if (graphDripData.balanceDrips.length > 0) {
      comptrollerAddress = graphDripData.balanceDrips[0].comptroller.id
    }
  }
  const { data: usersDripData, error: usersDripError } = useUsersDripQuery({
    provider: readProvider,
    comptrollerAddress,
    dripTokens,
    usersAddress,
    pairs,
    contractAddresses
  })
  if (usersDripError) {
    console.error(usersDripError)
  }
  return { graphDripData, usersDripData }
}
function useUsersDripData ( ) { const { address : usersAddress } = useOnboard ( ) const chainId = usePoolTokenChainId ( ) const readProvider = useReadProvider ( chainId ) const { contractAddresses } = useContractAddresses ( chainId ) const { data : graphDripData , error } = usePoolDripsQuery ( ) if ( error ) { console . error ( error ) } let pairs = [ ] let dripTokens = [ ] let comptrollerAddress if ( graphDripData ?. balanceDrips ) { const balanceDripPairs = graphDripData ?. balanceDrips . map ( ( drip ) => [ drip . sourceAddress , drip . measureToken ] ) const volumeDripPairs = graphDripData ?. volumeDrips . map ( ( drip ) => [ drip . sourceAddress , drip . measureToken ] ) pairs = uniqWith ( balanceDripPairs ?. concat ( volumeDripPairs ) , isEqual ) const balanceDripTokens = graphDripData ?. balanceDrips . map ( ( drip ) => drip . dripToken ) const volumeDripTokens = graphDripData ?. volumeDrips . map ( ( drip ) => drip . dripToken ) dripTokens = uniqWith ( balanceDripTokens ?. concat ( volumeDripTokens ) , isEqual ) if ( graphDripData . balanceDrips . length > 0 ) { comptrollerAddress = graphDripData . balanceDrips [ 0 ] . comptroller . id } } const { data : usersDripData , error : usersDripError } = useUsersDripQuery ( { provider : readProvider , comptrollerAddress , dripTokens , usersAddress , pairs , contractAddresses } ) if ( usersDripError ) { console . error ( usersDripError ) } return { graphDripData , usersDripData } }
can still claim from the drips.
can still claim from the drips .