diff --git a/schema.graphql b/schema.graphql index 0c5fe369..3b2dcd1c 100644 --- a/schema.graphql +++ b/schema.graphql @@ -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" diff --git a/src/mappings/disputeManager.ts b/src/mappings/disputeManager.ts index 624e54cc..7bce118b 100644 --- a/src/mappings/disputeManager.ts +++ b/src/mappings/disputeManager.ts @@ -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') @@ -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') diff --git a/src/mappings/horizonDisputeManager.ts b/src/mappings/horizonDisputeManager.ts index 6fdd3b70..d8ce3e3a 100644 --- a/src/mappings/horizonDisputeManager.ts +++ b/src/mappings/horizonDisputeManager.ts @@ -12,6 +12,7 @@ import { MaxSlashingCutSet, DisputeCancelled, DisputePeriodSet, + LegacyDisputeCreated, } from '../types/HorizonDisputeManager/HorizonDisputeManager' import { createOrLoadGraphNetwork } from './helpers/helpers' @@ -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 { @@ -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 @@ -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') @@ -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)! diff --git a/subgraph.template.yaml b/subgraph.template.yaml index 4774ea1c..24bd6723 100644 --- a/subgraph.template.yaml +++ b/subgraph.template.yaml @@ -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)