Skip to content

Commit

Permalink
feat(web, subgraph): add timestamp field to disputekitdispute, update…
Browse files Browse the repository at this point in the history
… query, get latest kit
  • Loading branch information
kemuru committed Oct 25, 2023
1 parent 978e954 commit 302ef1e
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
2 changes: 2 additions & 0 deletions subgraph/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ interface DisputeKitDispute {
coreDispute: Dispute!
localRounds: [DisputeKitRound!]! @derivedFrom(field: "localDispute")
currentLocalRoundIndex: BigInt!
timestamp: BigInt!
}

interface DisputeKitRound {
Expand Down Expand Up @@ -236,6 +237,7 @@ type ClassicDispute implements DisputeKitDispute @entity {
coreDispute: Dispute!
localRounds: [DisputeKitRound!]! @derivedFrom(field: "localDispute")
currentLocalRoundIndex: BigInt!
timestamp: BigInt!

numberOfChoices: BigInt!
extraData: Bytes!
Expand Down
1 change: 1 addition & 0 deletions subgraph/src/entities/ClassicDispute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
13 changes: 10 additions & 3 deletions web/src/hooks/queries/useClassicAppealQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -16,7 +16,7 @@ const classicAppealQuery = graphql(`
id
}
lastPeriodChange
disputeKitDispute {
disputeKitDispute(orderBy: $orderBy, orderDirection: $orderDirection) {
id
currentLocalRoundIndex
localRounds {
Expand All @@ -37,6 +37,13 @@ export const useClassicAppealQuery = (id?: string | number) => {
return useQuery<ClassicAppealQuery>({
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,
});
};
2 changes: 1 addition & 1 deletion web/src/hooks/useClassicAppealContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ const getCurrentLocalRound = (dispute?: ClassicAppealQuery["dispute"]) => {
if (!dispute) return undefined;

const period = dispute.period;
const currentLocalRoundIndex = dispute.disputeKitDispute[0]?.currentLocalRoundIndex;
const currentLocalRoundIndex = dispute.disputeKitDispute.at(-1)?.currentLocalRoundIndex;
const adjustedRoundIndex = ["appeal", "execution"].includes(period)
? currentLocalRoundIndex
: currentLocalRoundIndex - 1;
Expand Down

0 comments on commit 302ef1e

Please sign in to comment.