diff --git a/subgraph/schema.graphql b/subgraph/schema.graphql index ad646bee1..851cfc015 100644 --- a/subgraph/schema.graphql +++ b/subgraph/schema.graphql @@ -19,6 +19,7 @@ interface DisputeKitDispute { coreDispute: Dispute! localRounds: [DisputeKitRound!]! @derivedFrom(field: "localDispute") currentLocalRoundIndex: BigInt! + timestamp: BigInt! } interface DisputeKitRound { @@ -236,6 +237,7 @@ type ClassicDispute implements DisputeKitDispute @entity { coreDispute: Dispute! localRounds: [DisputeKitRound!]! @derivedFrom(field: "localDispute") currentLocalRoundIndex: BigInt! + timestamp: BigInt! numberOfChoices: BigInt! extraData: Bytes! diff --git a/subgraph/src/entities/ClassicDispute.ts b/subgraph/src/entities/ClassicDispute.ts index 9d49c7210..bc0604517 100644 --- a/subgraph/src/entities/ClassicDispute.ts +++ b/subgraph/src/entities/ClassicDispute.ts @@ -9,5 +9,6 @@ export function createClassicDisputeFromEvent(event: DisputeCreation): void { classicDispute.currentLocalRoundIndex = ZERO; classicDispute.numberOfChoices = event.params._numberOfChoices; classicDispute.extraData = event.params._extraData; + classicDispute.timestamp = event.block.timestamp; classicDispute.save(); } diff --git a/web/src/hooks/queries/useClassicAppealQuery.ts b/web/src/hooks/queries/useClassicAppealQuery.ts index bcdce6ebb..ff4eb4968 100644 --- a/web/src/hooks/queries/useClassicAppealQuery.ts +++ b/web/src/hooks/queries/useClassicAppealQuery.ts @@ -5,7 +5,7 @@ import { graphqlQueryFnHelper } from "utils/graphqlQueryFnHelper"; export type { ClassicAppealQuery }; const classicAppealQuery = graphql(` - query ClassicAppeal($disputeID: ID!) { + query ClassicAppeal($disputeID: ID!, $orderBy: DisputeKitDispute_orderBy, $orderDirection: OrderDirection) { dispute(id: $disputeID) { period court { @@ -16,7 +16,7 @@ const classicAppealQuery = graphql(` id } lastPeriodChange - disputeKitDispute { + disputeKitDispute(orderBy: $orderBy, orderDirection: $orderDirection) { id currentLocalRoundIndex localRounds { @@ -37,6 +37,13 @@ export const useClassicAppealQuery = (id?: string | number) => { return useQuery({ queryKey: ["refetchOnBlock", `classicAppealQuery${id}`], enabled: isEnabled, - queryFn: async () => await graphqlQueryFnHelper(classicAppealQuery, { disputeID: id?.toString() }), + queryFn: async () => + isEnabled + ? await graphqlQueryFnHelper(classicAppealQuery, { + disputeID: id?.toString(), + orderBy: "timestamp", + orderDirection: "asc", + }) + : undefined, }); }; diff --git a/web/src/hooks/useClassicAppealContext.tsx b/web/src/hooks/useClassicAppealContext.tsx index 59b2890ab..706b8577e 100644 --- a/web/src/hooks/useClassicAppealContext.tsx +++ b/web/src/hooks/useClassicAppealContext.tsx @@ -102,7 +102,7 @@ const getCurrentLocalRound = (dispute?: ClassicAppealQuery["dispute"]) => { if (!dispute) return undefined; const period = dispute.period; - const currentLocalRoundIndex = dispute.disputeKitDispute?.currentLocalRoundIndex; + const currentLocalRoundIndex = dispute.disputeKitDispute.at(-1)?.currentLocalRoundIndex; const adjustedRoundIndex = ["appeal", "execution"].includes(period) ? currentLocalRoundIndex : currentLocalRoundIndex - 1; diff --git a/web/src/pages/Cases/CaseDetails/Appeal/Classic/Options/StageOne.tsx b/web/src/pages/Cases/CaseDetails/Appeal/Classic/Options/StageOne.tsx index 765a1a7e2..5072dd81b 100644 --- a/web/src/pages/Cases/CaseDetails/Appeal/Classic/Options/StageOne.tsx +++ b/web/src/pages/Cases/CaseDetails/Appeal/Classic/Options/StageOne.tsx @@ -8,6 +8,7 @@ import { useOptionsContext, useSelectedOptionContext, } from "hooks/useClassicAppealContext"; +import { isUndefined } from "utils/index"; import { formatUnitsWei } from "utils/format"; const Container = styled.div` @@ -30,14 +31,15 @@ const StageOne: React.FC = ({ setAmount }) => { const options = useOptionsContext(); const loserSideCountdown = useLoserSideCountdownContext(); const { selectedOption, setSelectedOption } = useSelectedOptionContext(); + return ( - {typeof paidFees !== "undefined" && - typeof winnerRequiredFunding !== "undefined" && - typeof loserRequiredFunding !== "undefined" && + {!isUndefined(paidFees) && + !isUndefined(winnerRequiredFunding) && + !isUndefined(loserRequiredFunding) && options?.map((answer: string, i: number) => { const requiredFunding = i.toString() === winningChoice ? winnerRequiredFunding : loserRequiredFunding; return (