From 1b3a45fa8d9bfec9eaea9a1c04337d2992e08c8a Mon Sep 17 00:00:00 2001 From: jaybuidl Date: Mon, 12 Jun 2023 14:13:01 +0100 Subject: [PATCH] chore: subgraph update to reflect the latest contract deployment and event changes, wip --- subgraph/src/KlerosCore.ts | 46 +++++++++++++------------------------- subgraph/subgraph.yaml | 18 ++++++++------- 2 files changed, 25 insertions(+), 39 deletions(-) diff --git a/subgraph/src/KlerosCore.ts b/subgraph/src/KlerosCore.ts index 2eda07401..fe4bc689d 100644 --- a/subgraph/src/KlerosCore.ts +++ b/subgraph/src/KlerosCore.ts @@ -11,13 +11,11 @@ import { StakeSet, TokenAndETHShift as TokenAndETHShiftEvent, Ruling, + StakeDelayed, } from "../generated/KlerosCore/KlerosCore"; import { ZERO, ONE } from "./utils"; import { createCourtFromEvent, getFeeForJuror } from "./entities/Court"; -import { - createDisputeKitFromEvent, - filterSupportedDisputeKits, -} from "./entities/DisputeKit"; +import { createDisputeKitFromEvent, filterSupportedDisputeKits } from "./entities/DisputeKit"; import { createDisputeFromEvent } from "./entities/Dispute"; import { createRoundFromRoundInfo } from "./entities/Round"; import { @@ -29,15 +27,8 @@ import { updateCasesVoting, getDelta, } from "./datapoint"; -import { - addUserActiveDispute, - ensureUser, - resolveUserDispute, -} from "./entities/User"; -import { - ensureJurorTokensPerCourt, - updateJurorStake, -} from "./entities/JurorTokensPerCourt"; +import { addUserActiveDispute, ensureUser, resolveUserDispute } from "./entities/User"; +import { ensureJurorTokensPerCourt, updateJurorStake } from "./entities/JurorTokensPerCourt"; import { createDrawFromEvent } from "./entities/Draw"; import { createTokenAndEthShiftFromEvent } from "./entities/TokenAndEthShift"; import { updateArbitrableCases } from "./entities/Arbitrable"; @@ -146,12 +137,7 @@ export function handleDraw(event: DrawEvent): void { if (!dispute) return; const contract = KlerosCore.bind(event.address); const jurorAddress = event.params._address.toHexString(); - updateJurorStake( - jurorAddress, - dispute.court, - contract, - event.block.timestamp - ); + updateJurorStake(jurorAddress, dispute.court, contract, event.block.timestamp); addUserActiveDispute(jurorAddress, disputeID); } @@ -160,12 +146,15 @@ export function handleStakeSet(event: StakeSet): void { ensureUser(jurorAddress); const courtID = event.params._courtID; - updateJurorStake( - jurorAddress, - courtID.toString(), - KlerosCore.bind(event.address), - event.block.timestamp - ); + updateJurorStake(jurorAddress, courtID.toString(), KlerosCore.bind(event.address), event.block.timestamp); +} + +export function handleStakeDelayed(event: StakeDelayed): void { + const jurorAddress = event.params._address.toHexString(); + ensureUser(jurorAddress); + const courtID = event.params._courtID; + + // TODO: Update stake delayed } export function handleTokenAndETHShift(event: TokenAndETHShiftEvent): void { @@ -182,12 +171,7 @@ export function handleTokenAndETHShift(event: TokenAndETHShiftEvent): void { if (!dispute) return; const court = Court.load(dispute.court); if (!court) return; - updateJurorStake( - jurorAddress, - court.id, - KlerosCore.bind(event.address), - event.block.timestamp - ); + updateJurorStake(jurorAddress, court.id, KlerosCore.bind(event.address), event.block.timestamp); resolveUserDispute(jurorAddress, tokenAmount, disputeID); court.paidETH = court.paidETH.plus(ethAmount); court.paidPNK = court.paidPNK.plus(tokenAmount); diff --git a/subgraph/subgraph.yaml b/subgraph/subgraph.yaml index 33a0a1d95..3c959150f 100644 --- a/subgraph/subgraph.yaml +++ b/subgraph/subgraph.yaml @@ -6,9 +6,9 @@ dataSources: name: KlerosCore network: arbitrum-goerli source: - address: "0xD08Ab99480d02bf9C092828043f611BcDFEA917b" + address: "0xA429667Abb1A6c530BAd1083df4C69FBce86D696" abi: KlerosCore - startBlock: 9433950 + startBlock: 25602125 mapping: kind: ethereum/events apiVersion: 0.0.6 @@ -36,7 +36,7 @@ dataSources: handler: handleDraw - event: NewPeriod(indexed uint256,uint8) handler: handleNewPeriod - - event: CourtCreated(indexed uint256,indexed uint96,bool,uint256,uint256,uint256,uint256,uint256[4],uint256,uint256[]) + - event: CourtCreated(indexed uint256,indexed uint96,bool,uint256,uint256,uint256,uint256,uint256[4],uint256[]) handler: handleCourtCreated - event: CourtModified(indexed uint96,string) handler: handleCourtModified @@ -44,8 +44,10 @@ dataSources: handler: handleDisputeKitCreated - event: DisputeKitEnabled(indexed uint96,indexed uint256,indexed bool) handler: handleDisputeKitEnabled - - event: StakeSet(indexed address,uint256,uint256,uint256) + - event: StakeSet(indexed address,uint256,uint256) handler: handleStakeSet + - event: StakeDelayed(indexed address,uint256,uint256,uint256) + handler: handleStakeDelayed - event: TokenAndETHShift(indexed address,indexed uint256,indexed uint256,uint256,int256,int256) handler: handleTokenAndETHShift - event: Ruling(indexed address,indexed uint256,uint256) @@ -55,9 +57,9 @@ dataSources: name: PolicyRegistry network: arbitrum-goerli source: - address: "0xC5655728387Ce5E2aAA22138114E5777370aBDae" + address: "0xED503aBA65B28D81444294D1eAa5d84CeFdC2C58" abi: PolicyRegistry - startBlock: 6456907 + startBlock: 25585400 mapping: kind: ethereum/events apiVersion: 0.0.6 @@ -75,9 +77,9 @@ dataSources: name: DisputeKitClassic network: arbitrum-goerli source: - address: "0x0b24767Ae86Da2F5B442B2A524d3D9809CD0B5B2" + address: "0xcBE3aD699919Cf59efDF715e4B41AF30A0E4c92d" abi: DisputeKitClassic - startBlock: 9433943 + startBlock: 25602098 mapping: kind: ethereum/events apiVersion: 0.0.6