Skip to content

Commit

Permalink
chore: subgraph update to reflect the latest contract deployment and …
Browse files Browse the repository at this point in the history
…event changes, wip
  • Loading branch information
jaybuidl committed Jun 12, 2023
1 parent 4005d5a commit 1b3a45f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 39 deletions.
46 changes: 15 additions & 31 deletions subgraph/src/KlerosCore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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";
Expand Down Expand Up @@ -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);
}

Expand All @@ -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 {
Expand All @@ -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);
Expand Down
18 changes: 10 additions & 8 deletions subgraph/subgraph.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -36,16 +36,18 @@ 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
- event: DisputeKitCreated(indexed uint256,indexed address,indexed uint256)
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)
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 1b3a45f

Please sign in to comment.