Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only fetch factory on rinkeby #2236

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 59 additions & 57 deletions app/src/hooks/graph/useGraphMarketMakerData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,71 +5,73 @@ import gql from 'graphql-tag'
import { useEffect, useState } from 'react'

import { getLogger } from '../../util/logger'
import { getOutcomes } from '../../util/networks'
import { getOutcomes, networkIds } from '../../util/networks'
import { AnswerItem, BondItem, INVALID_ANSWER_ID, KlerosSubmission, Question, Status } from '../../util/types'

const logger = getLogger('useGraphMarketMakerData')

const query = gql`
query GetMarket($id: ID!) {
fixedProductMarketMaker(id: $id) {
id
creator
collateralToken
fee
collateralVolume
outcomeTokenAmounts
outcomeTokenMarginalPrices
condition {
const getQuery = (networkId: number) => {
return gql`
query GetMarket($id: ID!) {
fixedProductMarketMaker(id: $id) {
id
payouts
oracle
}
templateId
title
outcomes
category
language
lastActiveDay
runningDailyVolume
arbitrator
creationTimestamp
openingTimestamp
timeout
resolutionTimestamp
currentAnswer
currentAnswerTimestamp
currentAnswerBond
answerFinalizedTimestamp
scaledLiquidityParameter
runningDailyVolumeByHour
isPendingArbitration
arbitrationOccurred
runningDailyVolumeByHour
curatedByDxDao
curatedByDxDaoOrKleros
question {
id
data
creator
collateralToken
fee
collateralVolume
outcomeTokenAmounts
outcomeTokenMarginalPrices
condition {
id
payouts
oracle
}
templateId
title
outcomes
category
language
lastActiveDay
runningDailyVolume
arbitrator
creationTimestamp
openingTimestamp
timeout
resolutionTimestamp
currentAnswer
answers {
answer
bondAggregate
currentAnswerTimestamp
currentAnswerBond
answerFinalizedTimestamp
scaledLiquidityParameter
runningDailyVolumeByHour
isPendingArbitration
arbitrationOccurred
runningDailyVolumeByHour
curatedByDxDao
curatedByDxDaoOrKleros
question {
id
data
currentAnswer
answers {
answer
bondAggregate
}
}
klerosTCRregistered
curatedByDxDaoOrKleros
curatedByDxDao
submissionIDs {
id
status
}
scalarLow
scalarHigh
${networkId === networkIds.RINKEBY ? 'factory' : ''}
}
klerosTCRregistered
curatedByDxDaoOrKleros
curatedByDxDao
submissionIDs {
id
status
}
scalarLow
scalarHigh
factory
}
}
`
`
}

export type GraphResponseFixedProductMarketMaker = {
id: string
Expand Down Expand Up @@ -246,7 +248,7 @@ export const wrangleMarketDataResponse = (
*/
export const useGraphMarketMakerData = (marketMakerAddress: string, networkId: number): Result => {
const [marketMakerData, setMarketMakerData] = useState<Maybe<GraphMarketMakerData>>(null)

const query = getQuery(networkId)
const { data, error, loading, refetch } = useQuery<GraphResponse>(query, {
notifyOnNetworkStatusChange: true,
skip: false,
Expand Down
2 changes: 2 additions & 0 deletions app/src/hooks/market_data/useBlockchainMarketMakerData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ export const useBlockchainMarketMakerData = (graphMarketMakerData: Maybe<GraphMa
)

if (
graphMarketMakerData.factory &&
graphMarketMakerData.factory.toLowerCase() === getContractAddress(networkId, 'marketMakerFactory').toLowerCase()
) {
calls.push(
Expand Down Expand Up @@ -219,6 +220,7 @@ export const useBlockchainMarketMakerData = (graphMarketMakerData: Maybe<GraphMa

if (
!totalPoolShares.isZero() &&
graphMarketMakerData.factory &&
graphMarketMakerData.factory.toLowerCase() ===
getContractAddress(networkId, 'marketMakerFactory').toLowerCase()
) {
Expand Down