@@ -24,7 +24,7 @@ import { updateJurorStake } from "./entities/JurorTokensPerCourt";
2424import { createDrawFromEvent } from "./entities/Draw" ;
2525import { updateTokenAndEthShiftFromEvent } from "./entities/TokenAndEthShift" ;
2626import { updateArbitrableCases } from "./entities/Arbitrable" ;
27- import { Court , Dispute , User } from "../generated/schema" ;
27+ import { Court , Dispute , Round , User } from "../generated/schema" ;
2828import { BigInt } from "@graphprotocol/graph-ts" ;
2929import { updatePenalty } from "./entities/Penalty" ;
3030import { ensureFeeToken } from "./entities/FeeToken" ;
@@ -185,6 +185,17 @@ export function handleDraw(event: DrawEvent): void {
185185 const jurorAddress = event . params . _address . toHexString ( ) ;
186186 updateJurorStake ( jurorAddress , dispute . court , sortitionModule , event . block . timestamp ) ;
187187 addUserActiveDispute ( jurorAddress , disputeID ) ;
188+
189+ const roundIndex = event . params . _roundID ;
190+ const roundID = `${ disputeID } -${ roundIndex . toString ( ) } ` ;
191+
192+ const currentRound = Round . load ( roundID ) ;
193+ if ( ! currentRound ) return ;
194+
195+ if ( currentRound . nbVotes . toI32 ( ) === currentRound . drawnJurors . load ( ) . length ) {
196+ currentRound . jurorsDrawn = true ;
197+ currentRound . save ( ) ;
198+ }
188199}
189200
190201export function handleTokenAndETHShift ( event : TokenAndETHShiftEvent ) : void {
@@ -199,6 +210,21 @@ export function handleTokenAndETHShift(event: TokenAndETHShiftEvent): void {
199210 const klerosCore = KlerosCore . bind ( event . address ) ;
200211 const sortitionModule = SortitionModule . bind ( klerosCore . sortitionModule ( ) ) ;
201212 updateJurorStake ( jurorAddress , court . id , sortitionModule , event . block . timestamp ) ;
213+
214+ const roundIndex = event . params . _roundID ;
215+ const roundID = `${ disputeID } -${ roundIndex . toString ( ) } ` ;
216+
217+ const round = Round . load ( roundID ) ;
218+ if ( ! round ) return ;
219+
220+ const roundInfo = klerosCore . getRoundInfo ( event . params . _disputeID , roundIndex ) ;
221+ const repartitions = roundInfo . repartitions ;
222+ const nbVotes = roundInfo . nbVotes ;
223+
224+ if ( repartitions >= nbVotes ) {
225+ round . jurorRewardsDispersed = true ;
226+ round . save ( ) ;
227+ }
202228}
203229
204230export function handleAcceptedFeeToken ( event : AcceptedFeeToken ) : void {
0 commit comments