Skip to content

Commit 82fddfe

Browse files
authored
Merge pull request #301 from graphprotocol/mde/legacy-disputes
fix: added cancellableAt and LegacyDispute
2 parents 17e3772 + dc614ef commit 82fddfe

File tree

4 files changed

+31
-0
lines changed

4 files changed

+31
-0
lines changed

schema.graphql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1457,6 +1457,8 @@ type Dispute @entity(immutable: false) {
14571457
createdAt: Int!
14581458
"Time dispute was closed at"
14591459
closedAt: Int!
1460+
"Time dispute becomes cancellable by the fisherman"
1461+
cancellableAt: Int!
14601462
"Status of the dispute. Accepted means the Indexer was slashed"
14611463
status: DisputeStatus!
14621464
"Total amount of tokens slashed on the dispute"

src/mappings/disputeManager.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export function handleQueryDisputeCreated(event: QueryDisputeCreated): void {
2222
dispute.deposit = event.params.tokens
2323
dispute.isLegacy = true
2424
dispute.createdAt = event.block.timestamp.toI32()
25+
dispute.cancellableAt = 0 // Legacy disputes are not cancellable
2526
dispute.status = 'Undecided'
2627
dispute.tokensSlashed = BigDecimal.fromString('0')
2728
dispute.tokensBurned = BigDecimal.fromString('0')
@@ -60,6 +61,7 @@ export function handleIndexingDisputeCreated(event: IndexingDisputeCreated): voi
6061
dispute.deposit = event.params.tokens
6162
dispute.isLegacy = true
6263
dispute.createdAt = event.block.timestamp.toI32()
64+
dispute.cancellableAt = 0 // Legacy disputes are not cancellable
6365
dispute.status = 'Undecided'
6466
dispute.tokensSlashed = BigDecimal.fromString('0')
6567
dispute.tokensBurned = BigDecimal.fromString('0')

src/mappings/horizonDisputeManager.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
MaxSlashingCutSet,
1313
DisputeCancelled,
1414
DisputePeriodSet,
15+
LegacyDisputeCreated,
1516
} from '../types/HorizonDisputeManager/HorizonDisputeManager'
1617
import { createOrLoadGraphNetwork } from './helpers/helpers'
1718

@@ -32,6 +33,7 @@ const STATUS_CANCELLED = 'Cancelled'
3233
const TYPE_SINGLE_QUERY = 'SingleQuery'
3334
const TYPE_INDEXING = 'Indexing'
3435
const TYPE_CONFLICTING = 'Conflicting'
36+
const TYPE_LEGACY = 'Legacy'
3537

3638
// This handles Single query and Conflicting disputes
3739
export function handleQueryDisputeCreated(event: QueryDisputeCreated): void {
@@ -42,6 +44,7 @@ export function handleQueryDisputeCreated(event: QueryDisputeCreated): void {
4244
dispute.deposit = event.params.tokens
4345
dispute.isLegacy = false
4446
dispute.createdAt = event.block.timestamp.toI32()
47+
dispute.cancellableAt = event.params.cancellableAt.toI32()
4548
dispute.status = STATUS_UNDECIDED
4649
dispute.tokensSlashed = BIGDECIMAL_ZERO
4750
dispute.tokensRewarded = BIGINT_ZERO
@@ -80,6 +83,7 @@ export function handleIndexingDisputeCreated(event: IndexingDisputeCreated): voi
8083
dispute.deposit = event.params.tokens
8184
dispute.isLegacy = false
8285
dispute.createdAt = event.block.timestamp.toI32()
86+
dispute.cancellableAt = event.params.cancellableAt.toI32()
8387
dispute.status = STATUS_UNDECIDED
8488
dispute.tokensSlashed = BigDecimal.fromString('0')
8589
dispute.tokensBurned = BigDecimal.fromString('0')
@@ -91,6 +95,27 @@ export function handleIndexingDisputeCreated(event: IndexingDisputeCreated): voi
9195
dispute.save()
9296
}
9397

98+
export function handleLegacyDisputeCreated(event: LegacyDisputeCreated): void {
99+
let allocation = Allocation.load(event.params.allocationId.toHexString())!
100+
let id = event.params.disputeId.toHexString()
101+
let dispute = new Dispute(id)
102+
dispute.subgraphDeployment = allocation.subgraphDeployment
103+
dispute.fisherman = event.params.fisherman.toHexString()
104+
dispute.deposit = BigInt.fromString('0')
105+
dispute.isLegacy = true
106+
dispute.createdAt = event.block.timestamp.toI32()
107+
dispute.cancellableAt = 0 // Legacy disputes are not cancellable
108+
dispute.status = STATUS_UNDECIDED
109+
dispute.tokensSlashed = BigDecimal.fromString('0')
110+
dispute.tokensBurned = BigDecimal.fromString('0')
111+
dispute.tokensRewarded = BigInt.fromString('0')
112+
dispute.type = TYPE_LEGACY
113+
dispute.indexer = event.params.indexer.toHexString()
114+
dispute.allocation = allocation.id
115+
dispute.closedAt = 0
116+
dispute.save()
117+
}
118+
94119
export function handleDisputeAccepted(event: DisputeAccepted): void {
95120
let id = event.params.disputeId.toHexString()
96121
let dispute = Dispute.load(id)!

subgraph.template.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,8 @@ dataSources:
546546
handler: handleQueryDisputeCreated
547547
- event: IndexingDisputeCreated(indexed bytes32,indexed address,indexed address,uint256,address,bytes32,uint256,uint256)
548548
handler: handleIndexingDisputeCreated
549+
- event: LegacyDisputeCreated(indexed bytes32,indexed address,indexed address,address,uint256,uint256)
550+
handler: handleLegacyDisputeCreated
549551
- event: DisputeAccepted(indexed bytes32,indexed address,indexed address,uint256)
550552
handler: handleDisputeAccepted
551553
- event: DisputeRejected(indexed bytes32,indexed address,indexed address,uint256)

0 commit comments

Comments
 (0)