1
+ import { concat } from "../helpers/bytes"
1
2
import { buildId } from "../helpers/id"
2
3
import { createFeeMovement } from "./Treasury"
3
4
import { tryDecodingAgreementMetadata } from "../helpers/disputable"
7
8
BigInt ,
8
9
Address ,
9
10
ethereum ,
10
- log ,
11
+ ByteArray ,
11
12
} from "@graphprotocol/graph-ts"
12
13
import {
13
14
AdjudicationRound ,
@@ -96,7 +97,7 @@ export function handleJurorDrafted(event: JurorDrafted): void {
96
97
97
98
export function handleDisputeStateChanged ( event : DisputeStateChanged ) : void {
98
99
let dispute = Dispute . load ( event . params . disputeId . toString ( ) ) !
99
- dispute . state = castDisputeState ( Bytes . fromI32 ( event . params . state ) )
100
+ dispute . state = castDisputeState ( event . params . state )
100
101
dispute . save ( )
101
102
102
103
updateRound ( event . params . disputeId , dispute . lastRoundId , event )
@@ -107,7 +108,7 @@ export function handleDisputeStateChanged(event: DisputeStateChanged): void {
107
108
event . params . disputeId ,
108
109
dispute . lastRoundId ,
109
110
event
110
- )
111
+ ) !
111
112
round . draftedTermId = round . draftTermId . plus ( round . delayedTerms )
112
113
round . save ( )
113
114
}
@@ -124,7 +125,7 @@ export function handleRulingAppealConfirmed(
124
125
let manager = DisputeManager . bind ( event . address )
125
126
let dispute = new Dispute ( event . params . disputeId . toString ( ) )
126
127
let disputeResult = manager . getDispute ( event . params . disputeId )
127
- dispute . state = castDisputeState ( new Bytes ( disputeResult . value2 ) )
128
+ dispute . state = castDisputeState ( disputeResult . value2 )
128
129
dispute . lastRoundId = disputeResult . value4
129
130
dispute . save ( )
130
131
@@ -199,7 +200,7 @@ function updateRound(
199
200
roundNumber : BigInt ,
200
201
event : ethereum . Event
201
202
) : void {
202
- let round = loadOrCreateRound ( disputeId , roundNumber , event )
203
+ let round = loadOrCreateRound ( disputeId , roundNumber , event ) !
203
204
let manager = DisputeManager . bind ( event . address )
204
205
let result = manager . getRound ( disputeId , roundNumber )
205
206
round . number = roundNumber
@@ -212,7 +213,7 @@ function updateRound(
212
213
round . settledPenalties = result . value5
213
214
round . collectedTokens = result . value6
214
215
round . coherentJurors = result . value7
215
- round . state = castAdjudicationState ( Bytes . fromI32 ( result . value8 ) )
216
+ round . state = castAdjudicationState ( result . value8 )
216
217
round . stateInt = result . value8
217
218
round . save ( )
218
219
}
@@ -221,7 +222,7 @@ function loadOrCreateRound(
221
222
disputeId : BigInt ,
222
223
roundNumber : BigInt ,
223
224
event : ethereum . Event
224
- ) : AdjudicationRound {
225
+ ) : AdjudicationRound | null {
225
226
let id = buildRoundId ( disputeId , roundNumber ) . toString ( )
226
227
let round = AdjudicationRound . load ( id )
227
228
@@ -234,7 +235,10 @@ function loadOrCreateRound(
234
235
return round
235
236
}
236
237
237
- function createJurorDispute ( disputeId : BigInt , juror : Address ) : JurorDispute {
238
+ function createJurorDispute (
239
+ disputeId : BigInt ,
240
+ juror : Address
241
+ ) : JurorDispute | null {
238
242
let id = buildJurorDisputeId ( disputeId , juror ) . toString ( )
239
243
let jurorDispute = JurorDispute . load ( id )
240
244
@@ -253,7 +257,7 @@ function updateAppeal(
253
257
roundNumber : BigInt ,
254
258
event : ethereum . Event
255
259
) : void {
256
- let appeal = loadOrCreateAppeal ( disputeId , roundNumber , event )
260
+ let appeal = loadOrCreateAppeal ( disputeId , roundNumber , event ) !
257
261
let manager = DisputeManager . bind ( event . address )
258
262
let result = manager . getAppeal ( disputeId , roundNumber )
259
263
let nextRound = manager . getNextRoundDetails ( disputeId , roundNumber )
@@ -364,7 +368,7 @@ function loadOrCreateAppeal(
364
368
disputeId : BigInt ,
365
369
roundNumber : BigInt ,
366
370
event : ethereum . Event
367
- ) : Appeal {
371
+ ) : Appeal | null {
368
372
let id = buildAppealId ( disputeId , roundNumber ) . toString ( )
369
373
let appeal = Appeal . load ( id )
370
374
@@ -414,12 +418,10 @@ export function decodeDisputeRoundId(disputeRoundId: BigInt): BigInt[] {
414
418
}
415
419
416
420
export function buildDraftId ( roundId : BigInt , juror : Address ) : string {
417
- // @ts -ignore BigInt is actually a BytesArray under the hood
418
421
return crypto . keccak256 ( Bytes . fromBigInt ( roundId ) . concat ( juror ) ) . toHexString ( )
419
422
}
420
423
421
424
export function buildJurorDisputeId ( disputeId : BigInt , juror : Address ) : string {
422
- // @ts -ignore BigInt is actually a BytesArray under the hood
423
425
return crypto
424
426
. keccak256 ( Bytes . fromBigInt ( disputeId ) . concat ( juror ) )
425
427
. toHexString ( )
@@ -430,8 +432,8 @@ function buildAppealId(disputeId: BigInt, roundId: BigInt): BigInt {
430
432
return buildRoundId ( disputeId , roundId )
431
433
}
432
434
433
- function castDisputeState ( state : Bytes ) : string {
434
- switch ( state . toI32 ( ) ) {
435
+ function castDisputeState ( state : i32 ) : string {
436
+ switch ( state ) {
435
437
case 0 :
436
438
return "Drafting"
437
439
case 1 :
@@ -443,8 +445,8 @@ function castDisputeState(state: Bytes): string {
443
445
}
444
446
}
445
447
446
- function castAdjudicationState ( state : Bytes ) : string {
447
- switch ( state . toI32 ( ) ) {
448
+ function castAdjudicationState ( state : i32 ) : string {
449
+ switch ( state ) {
448
450
case 0 :
449
451
return "Invalid"
450
452
case 1 :
0 commit comments