Skip to content

Commit 6528829

Browse files
committed
fix: got the subgraph build to pass but some fixes are still required
1 parent d6cc3be commit 6528829

File tree

7 files changed

+31
-89
lines changed

7 files changed

+31
-89
lines changed

subgraph/core/schema.graphql

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ type User @entity {
7474
tokens: [JurorTokensPerCourt!]! @derivedFrom(field: "juror")
7575
totalStake: BigInt!
7676
totalDelayed: BigInt!
77-
shifts: [TokenAndETHShift!]! @derivedFrom(field: "juror")
77+
shifts: [JurorRewardPenalty!]! @derivedFrom(field: "juror")
7878
draws: [Draw!]! @derivedFrom(field: "juror")
7979
activeDisputes: BigInt!
8080
rounds: [Round!]!
@@ -99,7 +99,8 @@ type Penalty @entity {
9999
juror: User!
100100
amount: BigInt!
101101
numberDraws: BigInt!
102-
degreeOfCoherency: BigInt!
102+
degreeOfCoherencyPnk: BigInt!
103+
degreeOfCoherencyFee: BigInt!
103104
}
104105

105106
type Arbitrable @entity {
@@ -108,7 +109,7 @@ type Arbitrable @entity {
108109
totalDisputes: BigInt!
109110
}
110111

111-
type TokenAndETHShift @entity {
112+
type JurorRewardPenalty @entity {
112113
id: ID! # user.id-dispute.id
113114
juror: User!
114115
dispute: Dispute!
@@ -178,7 +179,7 @@ type Dispute @entity {
178179
currentRound: Round!
179180
currentRoundIndex: BigInt!
180181
jurors: [User!]! @derivedFrom(field: "disputes")
181-
shifts: [TokenAndETHShift!]! @derivedFrom(field: "dispute")
182+
shifts: [JurorRewardPenalty!]! @derivedFrom(field: "dispute")
182183
disputeKitDispute: [DisputeKitDispute!]! @derivedFrom(field: "coreDispute")
183184
isCrossChain: Boolean
184185
arbitrableChainId:BigInt
@@ -260,7 +261,7 @@ type FeeToken @entity {
260261
totalPaid: BigInt!
261262
totalPaidInETH: BigInt!
262263
rounds: [Round!] @derivedFrom(field: "feeToken")
263-
tokenAndETHShift: [TokenAndETHShift!] @derivedFrom(field: "feeToken")
264+
jurorRewardPenalty: [JurorRewardPenalty!] @derivedFrom(field: "feeToken")
264265
}
265266

266267
#####################

subgraph/core/src/DisputeKitClassic.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,9 @@ export function handleWithdrawal(event: Withdrawal): void {
181181

182182
// check if all appeal fees have been withdrawn
183183
const coreDisputeID = event.params._coreDisputeID.toString();
184-
const coreRoundIndex = event.params._coreRoundID.toString();
184+
185+
// TODO: handle the removal of _coreRoundID from the event
186+
const coreRoundIndex = 0; // event.params._coreRoundID.toString();
185187

186188
const coreDispute = Dispute.load(coreDisputeID);
187189
if (!coreDispute) return;

subgraph/core/src/EvidenceModule.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ import { ONE } from "./utils";
77
import { JSONValueToMaybeString } from "../../utils";
88

99
export function handleEvidenceEvent(event: EvidenceEvent): void {
10-
const evidenceGroupID = event.params._externalDisputeID.toString();
10+
// TODO: handle the replacement of _externalDisputeID with _arbitratorDisputeID
11+
// TODO: no more evidenceGroupID
12+
const evidenceGroupID = event.params._arbitratorDisputeID.toString();
13+
1114
const evidenceGroup = ensureClassicEvidenceGroup(evidenceGroupID);
1215
const evidenceIndex = evidenceGroup.nextEvidenceIndex;
1316
evidenceGroup.nextEvidenceIndex = evidenceGroup.nextEvidenceIndex.plus(ONE);

subgraph/core/src/KlerosCore.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
CourtModified,
99
Draw as DrawEvent,
1010
NewPeriod,
11-
TokenAndETHShift as TokenAndETHShiftEvent,
11+
JurorRewardPenalty as JurorRewardPenaltyEvent,
1212
CourtJump,
1313
Ruling,
1414
AcceptedFeeToken,
@@ -29,7 +29,7 @@ import {
2929
import { addUserActiveDispute, computeCoherenceScore, ensureUser } from "./entities/User";
3030
import { updateJurorStake } from "./entities/JurorTokensPerCourt";
3131
import { createDrawFromEvent } from "./entities/Draw";
32-
import { updateTokenAndEthShiftFromEvent } from "./entities/TokenAndEthShift";
32+
import { updateJurorRewardPenaltyEvent } from "./entities/JurorRewardPenalty";
3333
import { updateArbitrableCases } from "./entities/Arbitrable";
3434
import { ClassicVote, Court, Dispute, Draw, Round, User } from "../generated/schema";
3535
import { BigInt } from "@graphprotocol/graph-ts";
@@ -277,9 +277,9 @@ export function handleDraw(event: DrawEvent): void {
277277
}
278278
}
279279

280-
export function handleTokenAndETHShift(event: TokenAndETHShiftEvent): void {
280+
export function handleJurorRewardPenalty(event: JurorRewardPenaltyEvent): void {
281281
updatePenalty(event);
282-
updateTokenAndEthShiftFromEvent(event);
282+
updateJurorRewardPenaltyEvent(event);
283283
const jurorAddress = event.params._account.toHexString();
284284
const disputeID = event.params._disputeID.toString();
285285
const dispute = Dispute.load(disputeID);

subgraph/core/src/entities/ClassicContribution.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
import { ClassicContribution, Dispute, DisputeKit, Round } from "../../generated/schema";
1+
import { ClassicContribution, Dispute, Round } from "../../generated/schema";
22
import { Contribution as ContributionEvent, Withdrawal } from "../../generated/DisputeKitClassic/DisputeKitClassic";
33
import { ensureUser } from "./User";
44

55
export function ensureClassicContributionFromEvent<T>(event: T): ClassicContribution | null {
66
if (!(event instanceof ContributionEvent) && !(event instanceof Withdrawal)) return null;
77
const coreDisputeID = event.params._coreDisputeID.toString();
8-
const coreRoundIndex = event.params._coreRoundID.toString();
8+
9+
// TODO: handle the removal of _coreRoundID from the event
10+
const coreRoundIndex = 0; // event.params._coreRoundID.toString();
911

1012
const coreDispute = Dispute.load(coreDisputeID);
1113
if (!coreDispute) return null;
Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
1-
import { TokenAndETHShift } from "../../generated/KlerosCore/KlerosCore";
1+
import { JurorRewardPenalty } from "../../generated/KlerosCore/KlerosCore";
22
import { Penalty } from "../../generated/schema";
33
import { ONE } from "../utils";
44

5-
export function updatePenalty(event: TokenAndETHShift): void {
5+
export function updatePenalty(event: JurorRewardPenalty): void {
66
const disputeID = event.params._disputeID.toString();
77
const roundIndex = event.params._roundID.toString();
88
const roundID = `${disputeID}-${roundIndex}`;
99
const jurorAddress = event.params._account.toHexString();
1010
const penaltyID = `${roundID}-${jurorAddress}`;
1111
const penalty = Penalty.load(penaltyID);
1212
if (penalty) {
13-
penalty.amount = penalty.amount.plus(event.params._pnkAmount);
14-
const totalCoherency = penalty.degreeOfCoherency.times(penalty.numberDraws);
13+
penalty.amount = penalty.amount.plus(event.params._amountPnk);
14+
const totalCoherency = penalty.degreeOfCoherencyPnk.times(penalty.numberDraws);
1515
penalty.numberDraws = penalty.numberDraws.plus(ONE);
16-
penalty.degreeOfCoherency = totalCoherency.plus(penalty.degreeOfCoherency).div(penalty.numberDraws);
16+
penalty.degreeOfCoherencyPnk = totalCoherency.plus(penalty.degreeOfCoherencyPnk).div(penalty.numberDraws);
17+
// TODO: handle _degreeOfCoherencyFee
1718
penalty.save();
1819
} else {
1920
createPenalty(event);
2021
}
2122
}
2223

23-
export function createPenalty(event: TokenAndETHShift): void {
24+
export function createPenalty(event: JurorRewardPenalty): void {
2425
const disputeID = event.params._disputeID.toString();
2526
const roundIndex = event.params._roundID.toString();
2627
const roundID = `${disputeID}-${roundIndex}`;
@@ -31,7 +32,8 @@ export function createPenalty(event: TokenAndETHShift): void {
3132
penalty.round = roundID;
3233
penalty.juror = jurorAddress;
3334
penalty.numberDraws = ONE;
34-
penalty.amount = event.params._pnkAmount;
35-
penalty.degreeOfCoherency = event.params._degreeOfCoherency;
35+
penalty.amount = event.params._amountPnk;
36+
penalty.degreeOfCoherencyPnk = event.params._degreeOfCoherencyPnk;
37+
penalty.degreeOfCoherencyFee = event.params._degreeOfCoherencyFee;
3638
penalty.save();
3739
}

subgraph/core/src/entities/TokenAndEthShift.ts

Lines changed: 0 additions & 68 deletions
This file was deleted.

0 commit comments

Comments
 (0)