Skip to content

Support for Gated Dispute Kits and other improvements #2050

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Jul 28, 2025
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
3 changes: 1 addition & 2 deletions subgraph/core/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ export const ZERO = BigInt.fromI32(0);
export const ONE = BigInt.fromI32(1);

export function extractDisputeKitIDFromExtraData(extraData: Bytes): string {
const start = extraData.length - 32;
const littleEndian = extraData.subarray(start, extraData.length).reverse();
const littleEndian = extraData.subarray(64, 96).reverse();
return BigInt.fromUnsignedBytes(Bytes.fromUint8Array(littleEndian)).toString();
}
76 changes: 76 additions & 0 deletions subgraph/core/subgraph.template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,82 @@ dataSources:
- event: CommitCast(indexed uint256,indexed address,uint256[],bytes32)
handler: handleCommitCast
file: ./src/DisputeKitClassic.ts
- kind: ethereum
name: DisputeKitGated
network: _PLACEHOLDER_
source:
address: "_PLACEHOLDER_"
abi: DisputeKitGated
startBlock: _PLACEHOLDER_
mapping:
kind: ethereum/events
apiVersion: 0.0.7
language: wasm/assemblyscript
entities:
- ClassicDispute
- ClassicRound
- ClassicVote
- ClassicContribution
abis:
- name: DisputeKitGated
file: ../../contracts/deployments/_PLACEHOLDER_/DisputeKitGated.json
- name: DisputeKitClassic # Required on Alchemy
file: ../../contracts/deployments/_PLACEHOLDER_/DisputeKitClassic.json
- name: KlerosCore
# FIX: temporarily point to abi with event addition
file: ./abi-migrations/KlerosCore.json
eventHandlers:
- event: DisputeCreation(indexed uint256,uint256,bytes)
handler: handleDisputeCreation
- event: Contribution(indexed uint256,indexed uint256,uint256,indexed address,uint256)
handler: handleContributionEvent
- event: Withdrawal(indexed uint256,indexed uint256,uint256,indexed address,uint256)
handler: handleWithdrawal
- event: ChoiceFunded(indexed uint256,indexed uint256,indexed uint256)
handler: handleChoiceFunded
- event: VoteCast(indexed uint256,indexed address,uint256[],indexed uint256,string)
handler: handleVoteCast
- event: CommitCast(indexed uint256,indexed address,uint256[],bytes32)
handler: handleCommitCast
file: ./src/DisputeKitClassic.ts
- kind: ethereum
name: DisputeKitGatedShutter
network: _PLACEHOLDER_
source:
address: "_PLACEHOLDER_"
abi: DisputeKitGatedShutter
startBlock: _PLACEHOLDER_
mapping:
kind: ethereum/events
apiVersion: 0.0.7
language: wasm/assemblyscript
entities:
- ClassicDispute
- ClassicRound
- ClassicVote
- ClassicContribution
abis:
- name: DisputeKitGatedShutter
file: ../../contracts/deployments/_PLACEHOLDER_/DisputeKitGatedShutter.json
- name: DisputeKitClassic # Required on Alchemy
file: ../../contracts/deployments/_PLACEHOLDER_/DisputeKitClassic.json
- name: KlerosCore
# FIX: temporarily point to abi with event addition
file: ./abi-migrations/KlerosCore.json
eventHandlers:
- event: DisputeCreation(indexed uint256,uint256,bytes)
handler: handleDisputeCreation
- event: Contribution(indexed uint256,indexed uint256,uint256,indexed address,uint256)
handler: handleContributionEvent
- event: Withdrawal(indexed uint256,indexed uint256,uint256,indexed address,uint256)
handler: handleWithdrawal
- event: ChoiceFunded(indexed uint256,indexed uint256,indexed uint256)
handler: handleChoiceFunded
- event: VoteCast(indexed uint256,indexed address,uint256[],indexed uint256,string)
handler: handleVoteCast
- event: CommitCast(indexed uint256,indexed address,uint256[],bytes32)
handler: handleCommitCast
file: ./src/DisputeKitClassic.ts
- kind: ethereum
name: EvidenceModule
network: _PLACEHOLDER_
Expand Down
76 changes: 76 additions & 0 deletions subgraph/core/subgraph.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,82 @@ dataSources:
- event: CommitCast(indexed uint256,indexed address,uint256[],bytes32)
handler: handleCommitCast
file: ./src/DisputeKitClassic.ts
- kind: ethereum
name: DisputeKitGated
network: arbitrum-sepolia
source:
address: "0x677dA30B4b27D129354DdA1e219Bcc86802132d1"
abi: DisputeKitGated
startBlock: 175286139
mapping:
kind: ethereum/events
apiVersion: 0.0.7
language: wasm/assemblyscript
entities:
- ClassicDispute
- ClassicRound
- ClassicVote
- ClassicContribution
abis:
- name: DisputeKitGated
file: ../../contracts/deployments/arbitrumSepoliaDevnet/DisputeKitGated.json
- name: DisputeKitClassic # Required on Alchemy
file: ../../contracts/deployments/arbitrumSepoliaDevnet/DisputeKitClassic.json
- name: KlerosCore
# FIX: temporarily point to abi with event addition
file: ./abi-migrations/KlerosCore.json
eventHandlers:
- event: DisputeCreation(indexed uint256,uint256,bytes)
handler: handleDisputeCreation
- event: Contribution(indexed uint256,indexed uint256,uint256,indexed address,uint256)
handler: handleContributionEvent
- event: Withdrawal(indexed uint256,indexed uint256,uint256,indexed address,uint256)
handler: handleWithdrawal
- event: ChoiceFunded(indexed uint256,indexed uint256,indexed uint256)
handler: handleChoiceFunded
- event: VoteCast(indexed uint256,indexed address,uint256[],indexed uint256,string)
handler: handleVoteCast
- event: CommitCast(indexed uint256,indexed address,uint256[],bytes32)
handler: handleCommitCast
file: ./src/DisputeKitClassic.ts
- kind: ethereum
name: DisputeKitGatedShutter
network: arbitrum-sepolia
source:
address: "0xd86b84eb36Cd48f3f384b4490F255b494385F429"
abi: DisputeKitGatedShutter
startBlock: 175286153
mapping:
kind: ethereum/events
apiVersion: 0.0.7
language: wasm/assemblyscript
entities:
- ClassicDispute
- ClassicRound
- ClassicVote
- ClassicContribution
abis:
- name: DisputeKitGatedShutter
file: ../../contracts/deployments/arbitrumSepoliaDevnet/DisputeKitGatedShutter.json
- name: DisputeKitClassic # Required on Alchemy
file: ../../contracts/deployments/arbitrumSepoliaDevnet/DisputeKitClassic.json
- name: KlerosCore
# FIX: temporarily point to abi with event addition
file: ./abi-migrations/KlerosCore.json
eventHandlers:
- event: DisputeCreation(indexed uint256,uint256,bytes)
handler: handleDisputeCreation
- event: Contribution(indexed uint256,indexed uint256,uint256,indexed address,uint256)
handler: handleContributionEvent
- event: Withdrawal(indexed uint256,indexed uint256,uint256,indexed address,uint256)
handler: handleWithdrawal
- event: ChoiceFunded(indexed uint256,indexed uint256,indexed uint256)
handler: handleChoiceFunded
- event: VoteCast(indexed uint256,indexed address,uint256[],indexed uint256,string)
handler: handleVoteCast
- event: CommitCast(indexed uint256,indexed address,uint256[],bytes32)
handler: handleCommitCast
file: ./src/DisputeKitClassic.ts
- kind: ethereum
name: EvidenceModule
network: arbitrum-sepolia
Expand Down
2 changes: 1 addition & 1 deletion subgraph/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@kleros/kleros-v2-subgraph",
"version": "0.17.1",
"version": "0.17.2",
"drtVersion": "0.13.0",
"license": "MIT",
"scripts": {
Expand Down
17 changes: 6 additions & 11 deletions web/src/consts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,9 @@ export const RPC_ERROR = `RPC Error: Unable to fetch dispute data. Please avoid

export const spamEvidencesIds: string[] = (import.meta.env.REACT_APP_SPAM_EVIDENCES_IDS ?? "").split(",");

export const getDisputeKitName = (id: number): string | undefined => {
const universityDisputeKits: Record<number, string> = { 1: "Classic Dispute Kit" };
const neoDisputeKits: Record<number, string> = { 1: "Classic Dispute Kit" };
const testnetDisputeKits: Record<number, string> = { 1: "Classic Dispute Kit" };
const devnetDisputeKits: Record<number, string> = { 1: "Classic Dispute Kit", 2: "Shutter Dispute Kit" };

if (isKlerosUniversity()) return universityDisputeKits[id];
if (isKlerosNeo()) return neoDisputeKits[id];
if (isTestnetDeployment()) return testnetDisputeKits[id];
return devnetDisputeKits[id];
};
export enum DisputeKits {
Classic = "Classic",
Shutter = "Shutter",
Gated = "Token Gated",
GatedShutter = "Token Gated Shutter",
}
16 changes: 16 additions & 0 deletions web/src/context/NewDisputeContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,22 @@ interface IDisputeData extends IDisputeTemplate {
arbitrationCost?: string;
aliasesArray?: AliasArray[];
disputeKitId?: number;
disputeKitData?: IDisputeKitData;
}

export type IDisputeKitData = IGatedDisputeData | ISomeFutureDisputeData;

export interface IGatedDisputeData {
type: "gated";
isERC1155: boolean;
tokenGate: string;
tokenId: string;
}

// Placeholder
export interface ISomeFutureDisputeData {
type: "future";
contract: string;
}

interface INewDisputeContext {
Expand Down
1 change: 1 addition & 0 deletions web/src/hooks/queries/useDisputeDetailsQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const disputeDetailsQuery = graphql(`
nbVotes
disputeKit {
id
address
}
}
currentRoundIndex
Expand Down
7 changes: 7 additions & 0 deletions web/src/hooks/queries/useRoundDetailsQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ const roundDetailsQuery = graphql(`
disputeKit {
id
}
dispute {
disputeKitDispute {
... on ClassicDispute {
extraData
}
}
}
}
}
`);
Expand Down
3 changes: 3 additions & 0 deletions web/src/hooks/queries/useSupportedDisputeKits.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { useQuery } from "@tanstack/react-query";

import { useGraphqlBatcher } from "context/GraphqlBatcher";

import { graphql } from "src/graphql";
import { SupportedDisputeKitsQuery } from "src/graphql/graphql";

Expand All @@ -8,6 +10,7 @@ const supportedDisputeKitsQuery = graphql(`
court(id: $id) {
supportedDisputeKits {
id
address
}
}
}
Expand Down
Loading
Loading