Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -1457,6 +1457,8 @@ type Dispute @entity(immutable: false) {
createdAt: Int!
"Time dispute was closed at"
closedAt: Int!
"Time dispute becomes cancellable by the fisherman"
cancellableAt: Int!
"Status of the dispute. Accepted means the Indexer was slashed"
status: DisputeStatus!
"Total amount of tokens slashed on the dispute"
Expand Down
2 changes: 2 additions & 0 deletions src/mappings/disputeManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export function handleQueryDisputeCreated(event: QueryDisputeCreated): void {
dispute.deposit = event.params.tokens
dispute.isLegacy = true
dispute.createdAt = event.block.timestamp.toI32()
dispute.cancellableAt = 0 // Legacy disputes are not cancellable
dispute.status = 'Undecided'
dispute.tokensSlashed = BigDecimal.fromString('0')
dispute.tokensBurned = BigDecimal.fromString('0')
Expand Down Expand Up @@ -60,6 +61,7 @@ export function handleIndexingDisputeCreated(event: IndexingDisputeCreated): voi
dispute.deposit = event.params.tokens
dispute.isLegacy = true
dispute.createdAt = event.block.timestamp.toI32()
dispute.cancellableAt = 0 // Legacy disputes are not cancellable
dispute.status = 'Undecided'
dispute.tokensSlashed = BigDecimal.fromString('0')
dispute.tokensBurned = BigDecimal.fromString('0')
Expand Down
25 changes: 25 additions & 0 deletions src/mappings/horizonDisputeManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
MaxSlashingCutSet,
DisputeCancelled,
DisputePeriodSet,
LegacyDisputeCreated,
} from '../types/HorizonDisputeManager/HorizonDisputeManager'
import { createOrLoadGraphNetwork } from './helpers/helpers'

Expand All @@ -32,6 +33,7 @@ const STATUS_CANCELLED = 'Cancelled'
const TYPE_SINGLE_QUERY = 'SingleQuery'
const TYPE_INDEXING = 'Indexing'
const TYPE_CONFLICTING = 'Conflicting'
const TYPE_LEGACY = 'Legacy'

// This handles Single query and Conflicting disputes
export function handleQueryDisputeCreated(event: QueryDisputeCreated): void {
Expand All @@ -42,6 +44,7 @@ export function handleQueryDisputeCreated(event: QueryDisputeCreated): void {
dispute.deposit = event.params.tokens
dispute.isLegacy = false
dispute.createdAt = event.block.timestamp.toI32()
dispute.cancellableAt = event.params.cancellableAt.toI32()
dispute.status = STATUS_UNDECIDED
dispute.tokensSlashed = BIGDECIMAL_ZERO
dispute.tokensRewarded = BIGINT_ZERO
Expand Down Expand Up @@ -80,6 +83,7 @@ export function handleIndexingDisputeCreated(event: IndexingDisputeCreated): voi
dispute.deposit = event.params.tokens
dispute.isLegacy = false
dispute.createdAt = event.block.timestamp.toI32()
dispute.cancellableAt = event.params.cancellableAt.toI32()
dispute.status = STATUS_UNDECIDED
dispute.tokensSlashed = BigDecimal.fromString('0')
dispute.tokensBurned = BigDecimal.fromString('0')
Expand All @@ -91,6 +95,27 @@ export function handleIndexingDisputeCreated(event: IndexingDisputeCreated): voi
dispute.save()
}

export function handleLegacyDisputeCreated(event: LegacyDisputeCreated): void {
let allocation = Allocation.load(event.params.allocationId.toHexString())!
let id = event.params.disputeId.toHexString()
let dispute = new Dispute(id)
dispute.subgraphDeployment = allocation.subgraphDeployment
dispute.fisherman = event.params.fisherman.toHexString()
dispute.deposit = BigInt.fromString('0')
dispute.isLegacy = true
dispute.createdAt = event.block.timestamp.toI32()
dispute.cancellableAt = 0 // Legacy disputes are not cancellable
dispute.status = STATUS_UNDECIDED
dispute.tokensSlashed = BigDecimal.fromString('0')
dispute.tokensBurned = BigDecimal.fromString('0')
dispute.tokensRewarded = BigInt.fromString('0')
dispute.type = TYPE_LEGACY
dispute.indexer = event.params.indexer.toHexString()
dispute.allocation = allocation.id
dispute.closedAt = 0
dispute.save()
}

export function handleDisputeAccepted(event: DisputeAccepted): void {
let id = event.params.disputeId.toHexString()
let dispute = Dispute.load(id)!
Expand Down
2 changes: 2 additions & 0 deletions subgraph.template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,8 @@ dataSources:
handler: handleQueryDisputeCreated
- event: IndexingDisputeCreated(indexed bytes32,indexed address,indexed address,uint256,address,bytes32,uint256,uint256)
handler: handleIndexingDisputeCreated
- event: LegacyDisputeCreated(indexed bytes32,indexed address,indexed address,address,uint256,uint256)
handler: handleLegacyDisputeCreated
- event: DisputeAccepted(indexed bytes32,indexed address,indexed address,uint256)
handler: handleDisputeAccepted
- event: DisputeRejected(indexed bytes32,indexed address,indexed address,uint256)
Expand Down