Skip to content

Commit a390638

Browse files
committed
fix(subgraph): use updatePenalty correctly and fix init bug
1 parent 293ff00 commit a390638

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

subgraph/src/KlerosCore.ts

+2
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import { createTokenAndEthShiftFromEvent } from "./entities/TokenAndEthShift";
4343
import { updateArbitrableCases } from "./entities/Arbitrable";
4444
import { Court, Dispute } from "../generated/schema";
4545
import { BigInt } from "@graphprotocol/graph-ts";
46+
import { updatePenalty } from "./entities/Penalty";
4647

4748
function getPeriodName(index: i32): string {
4849
const periodArray = ["evidence", "commit", "vote", "appeal", "execution"];
@@ -191,4 +192,5 @@ export function handleTokenAndETHShift(event: TokenAndETHShiftEvent): void {
191192
court.paidETH = court.paidETH.plus(ethAmount);
192193
court.paidPNK = court.paidPNK.plus(tokenAmount);
193194
court.save();
195+
updatePenalty(event);
194196
}

subgraph/src/entities/Penalty.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { TokenAndETHShift } from "../../generated/KlerosCore/KlerosCore";
22
import { Penalty } from "../../generated/schema";
3-
import { ONE, ZERO } from "../utils";
3+
import { ONE } from "../utils";
44

55
export function updatePenalty(event: TokenAndETHShift): void {
66
const disputeID = event.params._disputeID.toString();
@@ -17,8 +17,9 @@ export function updatePenalty(event: TokenAndETHShift): void {
1717
.plus(penalty.degreeOfCoherency)
1818
.div(penalty.numberDraws);
1919
penalty.save();
20+
} else {
21+
createPenalty(event);
2022
}
21-
createPenalty(event);
2223
}
2324

2425
export function createPenalty(event: TokenAndETHShift): void {
@@ -31,7 +32,7 @@ export function createPenalty(event: TokenAndETHShift): void {
3132
penalty.dispute = disputeID;
3233
penalty.round = roundID;
3334
penalty.juror = jurorAddress;
34-
penalty.numberDraws = ZERO;
35+
penalty.numberDraws = ONE;
3536
penalty.amount = event.params._tokenAmount;
3637
penalty.degreeOfCoherency = event.params._degreeOfCoherency;
3738
penalty.save();

0 commit comments

Comments
 (0)