From d50e4e3b1f52c3032f777cd7d5b4368a011f7c82 Mon Sep 17 00:00:00 2001 From: alcercu Date: Tue, 31 Jan 2023 16:52:48 +0100 Subject: [PATCH 1/5] feat(subgraph): handle new Ruling event --- subgraph/src/KlerosCore.ts | 20 +++++++++++++++++++- subgraph/subgraph.yaml | 2 ++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/subgraph/src/KlerosCore.ts b/subgraph/src/KlerosCore.ts index 437fa0314..b88477d72 100644 --- a/subgraph/src/KlerosCore.ts +++ b/subgraph/src/KlerosCore.ts @@ -10,6 +10,7 @@ import { NewPeriod, StakeSet, TokenAndETHShift as TokenAndETHShiftEvent, + Ruling, } from "../generated/KlerosCore/KlerosCore"; import { ZERO, ONE } from "./utils"; import { createCourtFromEvent, getFeeForJuror } from "./entities/Court"; @@ -24,6 +25,8 @@ import { updatePaidETH, updateStakedPNK, updateRedistributedPNK, + updateCasesRuled, + updateCasesVoting, getDelta, } from "./datapoint"; import { ensureUser } from "./entities/User"; @@ -35,6 +38,7 @@ import { createDrawFromEvent } from "./entities/Draw"; import { createTokenAndEthShiftFromEvent } from "./entities/TokenAndEthShift"; import { updateArbitrableCases } from "./entities/Arbitrable"; import { Court, Dispute } from "../generated/schema"; +import { BigInt } from "@graphprotocol/graph-ts"; function getPeriodName(index: i32): string { const periodArray = ["evidence", "commit", "vote", "appeal", "execution"]; @@ -95,11 +99,25 @@ export function handleNewPeriod(event: NewPeriod): void { const disputeID = event.params._disputeID.toString(); const dispute = Dispute.load(disputeID); if (!dispute) return; - dispute.period = getPeriodName(event.params._period); + const newPeriod = getPeriodName(event.params._period); + if (dispute.period === "vote") { + updateCasesVoting(BigInt.fromI32(-1), event.block.timestamp); + } else if (newPeriod === "vote") { + updateCasesVoting(ONE, event.block.timestamp); + } + dispute.period = newPeriod; dispute.lastPeriodChange = event.block.timestamp; dispute.save(); } +export function handleRuling(event: Ruling): void { + const disputeID = event.params._disputeID.toString(); + const dispute = Dispute.load(disputeID); + if (!dispute) return; + dispute.ruled = true; + updateCasesRuled(ONE, event.block.timestamp); +} + export function handleAppealDecision(event: AppealDecision): void { const contract = KlerosCore.bind(event.address); const disputeID = event.params._disputeID; diff --git a/subgraph/subgraph.yaml b/subgraph/subgraph.yaml index 064578689..21de3b1bc 100644 --- a/subgraph/subgraph.yaml +++ b/subgraph/subgraph.yaml @@ -48,6 +48,8 @@ dataSources: handler: handleStakeSet - event: TokenAndETHShift(indexed address,indexed uint256,int256,int256) handler: handleTokenAndETHShift + - event: Ruling(indexed address,uint256,uint256) + handler: handleRuling file: ./src/KlerosCore.ts - kind: ethereum name: PolicyRegistry From 798372b66c0d4d44539dcee4c7dc2a18927816f3 Mon Sep 17 00:00:00 2001 From: alcercu Date: Tue, 31 Jan 2023 16:53:16 +0100 Subject: [PATCH 2/5] fix(subgraph): correctly stringify evidence group id --- subgraph/src/DisputeKitClassic.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subgraph/src/DisputeKitClassic.ts b/subgraph/src/DisputeKitClassic.ts index 7d3704bea..6d0a7e9f4 100644 --- a/subgraph/src/DisputeKitClassic.ts +++ b/subgraph/src/DisputeKitClassic.ts @@ -35,7 +35,7 @@ export function handleDisputeCreation(event: DisputeCreation): void { } export function handleEvidenceEvent(event: EvidenceEvent): void { - const evidenceGroupID = event.params._evidenceGroupID.toHexString(); + const evidenceGroupID = event.params._evidenceGroupID.toString(); const evidenceGroup = ensureClassicEvidenceGroup(evidenceGroupID); const evidenceIndex = evidenceGroup.nextEvidenceIndex; evidenceGroup.nextEvidenceIndex = evidenceGroup.nextEvidenceIndex.plus(ONE); From be008d57e2f21020e323b2c93d8174256245e11f Mon Sep 17 00:00:00 2001 From: alcercu Date: Fri, 3 Feb 2023 12:04:19 +0100 Subject: [PATCH 3/5] fix(subgraph): event definition subgraph config --- subgraph/subgraph.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/subgraph/subgraph.yaml b/subgraph/subgraph.yaml index 21de3b1bc..1560bc181 100644 --- a/subgraph/subgraph.yaml +++ b/subgraph/subgraph.yaml @@ -48,7 +48,7 @@ dataSources: handler: handleStakeSet - event: TokenAndETHShift(indexed address,indexed uint256,int256,int256) handler: handleTokenAndETHShift - - event: Ruling(indexed address,uint256,uint256) + - event: Ruling(indexed address,indexed uint256,uint256) handler: handleRuling file: ./src/KlerosCore.ts - kind: ethereum @@ -101,7 +101,7 @@ dataSources: handler: handleWithdrawal - event: ChoiceFunded(indexed uint256,indexed uint256,indexed uint256) handler: handleChoiceFunded - - event: Evidence(indexed address,indexed uint256,indexed address,string) + - event: Evidence(indexed uint256,indexed address,string) handler: handleEvidenceEvent - event: Justification(indexed uint256,indexed address,indexed uint256,string) handler: handleJustificationEvent From 9ecc9d3709e529e5a0708a1b868d3102bdb76297 Mon Sep 17 00:00:00 2001 From: alcercu Date: Fri, 3 Feb 2023 12:07:43 +0100 Subject: [PATCH 4/5] fix(subgraph): update contract addresses --- subgraph/subgraph.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/subgraph/subgraph.yaml b/subgraph/subgraph.yaml index 1560bc181..57dc2ade2 100644 --- a/subgraph/subgraph.yaml +++ b/subgraph/subgraph.yaml @@ -6,7 +6,7 @@ dataSources: name: KlerosCore network: arbitrum-goerli source: - address: "0x4d7858e73a8842b5e6422D08a3349924dD062AbB" + address: "0x3eED6aaCa43f4Bb98C591e4A0d2C4a124efF9C24" abi: KlerosCore startBlock: 4027978 mapping: @@ -55,7 +55,7 @@ dataSources: name: PolicyRegistry network: arbitrum-goerli source: - address: "0xAF0F49Fe110b48bd512F00d51D141F023c9a9106" + address: "0xC5655728387Ce5E2aAA22138114E5777370aBDae" abi: PolicyRegistry startBlock: 4027973 mapping: @@ -75,7 +75,7 @@ dataSources: name: DisputeKitClassic network: arbitrum-goerli source: - address: "0xde31F2245d164620d08f5b0f8D43dCe8B9708373" + address: "0x86734488ABF0E1AD40bc4DE4F820e808f39Bea09" abi: DisputeKitClassic startBlock: 4027976 mapping: From fa924a4aadee151b50adb190272ed6b208a23e10 Mon Sep 17 00:00:00 2001 From: alcercu Date: Fri, 3 Feb 2023 12:08:53 +0100 Subject: [PATCH 5/5] chore(subgraph): update start blocks --- subgraph/subgraph.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/subgraph/subgraph.yaml b/subgraph/subgraph.yaml index 57dc2ade2..a10916488 100644 --- a/subgraph/subgraph.yaml +++ b/subgraph/subgraph.yaml @@ -8,7 +8,7 @@ dataSources: source: address: "0x3eED6aaCa43f4Bb98C591e4A0d2C4a124efF9C24" abi: KlerosCore - startBlock: 4027978 + startBlock: 6456845 mapping: kind: ethereum/events apiVersion: 0.0.6 @@ -57,7 +57,7 @@ dataSources: source: address: "0xC5655728387Ce5E2aAA22138114E5777370aBDae" abi: PolicyRegistry - startBlock: 4027973 + startBlock: 6456907 mapping: kind: ethereum/events apiVersion: 0.0.6 @@ -77,7 +77,7 @@ dataSources: source: address: "0x86734488ABF0E1AD40bc4DE4F820e808f39Bea09" abi: DisputeKitClassic - startBlock: 4027976 + startBlock: 6456825 mapping: kind: ethereum/events apiVersion: 0.0.6