Skip to content

Commit

Permalink
fix(subgraph): voting and appealing cases count
Browse files Browse the repository at this point in the history
  • Loading branch information
alcercu committed Oct 6, 2023
1 parent 2048cff commit f29a40d
Showing 2 changed files with 14 additions and 15 deletions.
8 changes: 4 additions & 4 deletions subgraph/src/KlerosCore.ts
Original file line number Diff line number Diff line change
@@ -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();
}
21 changes: 10 additions & 11 deletions subgraph/src/entities/Round.ts
Original file line number Diff line number Diff line change
@@ -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();
}

0 comments on commit f29a40d

Please sign in to comment.