From e81a3e446a2a646aecb3a137a761e6d23a614b0b Mon Sep 17 00:00:00 2001 From: hexyls Date: Thu, 2 Sep 2021 16:21:07 +1000 Subject: [PATCH] fix: only fetch factory on rinkeby --- .../hooks/graph/useGraphMarketMakerData.tsx | 116 +++++++++--------- .../useBlockchainMarketMakerData.tsx | 2 + 2 files changed, 61 insertions(+), 57 deletions(-) diff --git a/app/src/hooks/graph/useGraphMarketMakerData.tsx b/app/src/hooks/graph/useGraphMarketMakerData.tsx index 6db044da2..2d346a0af 100644 --- a/app/src/hooks/graph/useGraphMarketMakerData.tsx +++ b/app/src/hooks/graph/useGraphMarketMakerData.tsx @@ -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 @@ -246,7 +248,7 @@ export const wrangleMarketDataResponse = ( */ export const useGraphMarketMakerData = (marketMakerAddress: string, networkId: number): Result => { const [marketMakerData, setMarketMakerData] = useState>(null) - + const query = getQuery(networkId) const { data, error, loading, refetch } = useQuery(query, { notifyOnNetworkStatusChange: true, skip: false, diff --git a/app/src/hooks/market_data/useBlockchainMarketMakerData.tsx b/app/src/hooks/market_data/useBlockchainMarketMakerData.tsx index 2402c6845..33a3fdb15 100644 --- a/app/src/hooks/market_data/useBlockchainMarketMakerData.tsx +++ b/app/src/hooks/market_data/useBlockchainMarketMakerData.tsx @@ -152,6 +152,7 @@ export const useBlockchainMarketMakerData = (graphMarketMakerData: Maybe