@@ -20,7 +20,7 @@ import { createDisputeFromEvent } from "./entities/Dispute";
2020import { createRoundFromRoundInfo } from "./entities/Round" ;
2121import { updateCases , updateCasesAppealing , updateCasesRuled , updateCasesVoting } from "./datapoint" ;
2222import { addUserActiveDispute , ensureUser } from "./entities/User" ;
23- import { updateJurorDelayedStake , updateJurorStake } from "./entities/JurorTokensPerCourt" ;
23+ import { updateJurorStake } from "./entities/JurorTokensPerCourt" ;
2424import { createDrawFromEvent } from "./entities/Draw" ;
2525import { updateTokenAndEthShiftFromEvent } from "./entities/TokenAndEthShift" ;
2626import { updateArbitrableCases } from "./entities/Arbitrable" ;
@@ -29,6 +29,7 @@ import { BigInt } from "@graphprotocol/graph-ts";
2929import { updatePenalty } from "./entities/Penalty" ;
3030import { ensureFeeToken } from "./entities/FeeToken" ;
3131import { getAndIncrementPeriodCounter } from "./entities/PeriodIndexCounter" ;
32+ import { SortitionModule } from "../generated/SortitionModule/SortitionModule" ;
3233
3334function getPeriodName ( index : i32 ) : string {
3435 const periodArray = [ "evidence" , "commit" , "vote" , "appeal" , "execution" ] ;
@@ -177,31 +178,14 @@ export function handleDraw(event: DrawEvent): void {
177178 const disputeID = event . params . _disputeID . toString ( ) ;
178179 const dispute = Dispute . load ( disputeID ) ;
179180 if ( ! dispute ) return ;
180- const contract = KlerosCore . bind ( event . address ) ;
181+ const klerosCore = KlerosCore . bind ( event . address ) ;
182+ const sortitionModule = SortitionModule . bind ( klerosCore . sortitionModule ( ) ) ;
183+
181184 const jurorAddress = event . params . _address . toHexString ( ) ;
182- updateJurorStake ( jurorAddress , dispute . court , contract , event . block . timestamp ) ;
185+ updateJurorStake ( jurorAddress , dispute . court , sortitionModule , event . block . timestamp ) ;
183186 addUserActiveDispute ( jurorAddress , disputeID ) ;
184187}
185188
186- // TODO: index the sortition module and handle these events there
187- // export function handleStakeSet(event: StakeSet): void {
188- // const jurorAddress = event.params._address.toHexString();
189- // ensureUser(jurorAddress);
190- // const courtID = event.params._courtID.toString();
191-
192- // updateJurorStake(jurorAddress, courtID.toString(), KlerosCore.bind(event.address), event.block.timestamp);
193-
194- // // Check if the transaction the event comes from is executeDelayedStakes
195- // if (event.transaction.input.toHexString().substring(0, 10) === "0x35975f4a") {
196- // updateJurorDelayedStake(jurorAddress, courtID, ZERO.minus(event.params._amount));
197- // }
198- // }
199-
200- // TODO: index the sortition module and handle these events there
201- // export function handleStakeDelayedNotTransferred(event: StakeDelayedNotTransferred): void {
202- // updateJurorDelayedStake(event.params._address.toHexString(), event.params._courtID.toString(), event.params._amount);
203- // }
204-
205189export function handleTokenAndETHShift ( event : TokenAndETHShiftEvent ) : void {
206190 updatePenalty ( event ) ;
207191 updateTokenAndEthShiftFromEvent ( event ) ;
@@ -211,7 +195,9 @@ export function handleTokenAndETHShift(event: TokenAndETHShiftEvent): void {
211195 if ( ! dispute ) return ;
212196 const court = Court . load ( dispute . court ) ;
213197 if ( ! court ) return ;
214- updateJurorStake ( jurorAddress , court . id , KlerosCore . bind ( event . address ) , event . block . timestamp ) ;
198+ const klerosCore = KlerosCore . bind ( event . address ) ;
199+ const sortitionModule = SortitionModule . bind ( klerosCore . sortitionModule ( ) ) ;
200+ updateJurorStake ( jurorAddress , court . id , sortitionModule , event . block . timestamp ) ;
215201}
216202
217203export function handleAcceptedFeeToken ( event : AcceptedFeeToken ) : void {
0 commit comments