From f29a40d9def7fad2cc354db4fae7214f161872c6 Mon Sep 17 00:00:00 2001 From: alcercu <333aleix333@gmail.com> Date: Fri, 6 Oct 2023 19:13:49 +0200 Subject: [PATCH] fix(subgraph): voting and appealing cases count --- subgraph/src/KlerosCore.ts | 8 ++++---- subgraph/src/entities/Round.ts | 21 ++++++++++----------- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/subgraph/src/KlerosCore.ts b/subgraph/src/KlerosCore.ts index 738b39043..3c0efc480 100644 --- a/subgraph/src/KlerosCore.ts +++ b/subgraph/src/KlerosCore.ts @@ -90,13 +90,13 @@ export function handleNewPeriod(event: NewPeriod): void { const court = Court.load(dispute.court); if (!court) return; - if (dispute.period === "vote") { + if (dispute.period.includes("vote")) { court.numberVotingDisputes = court.numberVotingDisputes.minus(ONE); updateCasesVoting(BigInt.fromI32(-1), event.block.timestamp); - } else if (dispute.period === "appeal") { + } else if (dispute.period.includes("appeal")) { let juror: User; for (let i = 0; i < dispute.jurors.entries.length; i++) { - juror = ensureUser(dispute.jurors.entries[0].value.toString()); + juror = ensureUser(dispute.jurors.entries[i].value.toString()); juror.totalAppealingDisputes = juror.totalAppealingDisputes.minus(ONE); juror.save(); } @@ -111,7 +111,7 @@ export function handleNewPeriod(event: NewPeriod): void { } else if (newPeriod === "appeal") { let juror: User; for (let i = 0; i < dispute.jurors.entries.length; i++) { - juror = ensureUser(dispute.jurors.entries[0].value.toString()); + juror = ensureUser(dispute.jurors.entries[i].value.toString()); juror.totalAppealingDisputes = juror.totalAppealingDisputes.plus(ONE); juror.save(); } diff --git a/subgraph/src/entities/Round.ts b/subgraph/src/entities/Round.ts index 39fb2c038..731f43773 100644 --- a/subgraph/src/entities/Round.ts +++ b/subgraph/src/entities/Round.ts @@ -1,23 +1,22 @@ import { BigInt } from "@graphprotocol/graph-ts"; -import { KlerosCore__getRoundInfoResultValue0Struct } from "../../generated/KlerosCore/KlerosCore"; +import { KlerosCore__getRoundInfoResult } from "../../generated/KlerosCore/KlerosCore"; import { Round } from "../../generated/schema"; export function createRoundFromRoundInfo( disputeID: BigInt, roundIndex: BigInt, - roundInfo: KlerosCore__getRoundInfoResultValue0Struct + roundInfo: KlerosCore__getRoundInfoResult ): void { const roundID = `${disputeID.toString()}-${roundIndex.toString()}`; const round = new Round(roundID); - const feeToken = roundInfo.feeToken; - round.disputeKit = roundInfo.disputeKitID.toString(); - round.tokensAtStakePerJuror = roundInfo.pnkAtStakePerJuror; - round.totalFeesForJurors = roundInfo.totalFeesForJurors; - round.nbVotes = roundInfo.nbVotes; - round.repartitions = roundInfo.repartitions; - round.penalties = roundInfo.pnkPenalties; + const feeToken = roundInfo.getFeeToken().toHexString(); + round.feeToken = feeToken === "0x0000000000000000000000000000000000000000" ? null : feeToken; + round.disputeKit = roundInfo.getDisputeKitID().toString(); + round.tokensAtStakePerJuror = roundInfo.getPnkAtStakePerJuror(); + round.totalFeesForJurors = roundInfo.getTotalFeesForJurors(); + round.nbVotes = roundInfo.getNbVotes(); + round.repartitions = roundInfo.getRepartitions(); + round.penalties = roundInfo.getPnkPenalties(); round.dispute = disputeID.toString(); - round.feeToken = - feeToken.toHexString() === "0x0000000000000000000000000000000000000000" ? null : feeToken.toHexString(); round.save(); }