From 1f8aee2c389b5e4f415d53dd21e46ec1e3af3acf Mon Sep 17 00:00:00 2001 From: alcercu Date: Fri, 27 Jan 2023 16:36:18 +0100 Subject: [PATCH] fix(subgraph): correctly derive votes field in classic round --- subgraph/schema.graphql | 3 ++- subgraph/src/entities/ClassicRound.ts | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/subgraph/schema.graphql b/subgraph/schema.graphql index 2cad533d4..c9abe1630 100644 --- a/subgraph/schema.graphql +++ b/subgraph/schema.graphql @@ -24,6 +24,7 @@ interface DisputeKitDispute { interface DisputeKitRound { id: ID! localDispute: DisputeKitDispute! + votes: [Vote!]! @derivedFrom(field: "localRound") } interface Vote { @@ -185,8 +186,8 @@ type ClassicDispute implements DisputeKitDispute @entity { type ClassicRound implements DisputeKitRound @entity { id: ID! # disputeKit.id-coreDispute-dispute.rounds.length localDispute: DisputeKitDispute! + votes: [Vote!]! @derivedFrom(field: "localRound") - votes: [ClassicVote!]! winningChoice: BigInt! counts: [BigInt!]! tied: Boolean! diff --git a/subgraph/src/entities/ClassicRound.ts b/subgraph/src/entities/ClassicRound.ts index afed8be9e..6024c35b0 100644 --- a/subgraph/src/entities/ClassicRound.ts +++ b/subgraph/src/entities/ClassicRound.ts @@ -13,7 +13,6 @@ export function createClassicRound( const id = `${localDisputeID}-${roundIndex.toString()}`; const classicRound = new ClassicRound(id); classicRound.localDispute = localDisputeID; - classicRound.votes = []; classicRound.winningChoice = ZERO; classicRound.counts = new Array(choicesLength.toI32()).fill(ZERO); classicRound.tied = true; @@ -42,6 +41,7 @@ export function updateCounts(id: string, choice: BigInt): void { round.tied = false; } } + round.totalVoted = round.totalVoted.plus(ONE); round.save(); }