Skip to content

Commit bff4f10

Browse files
authored
Merge pull request #2050 from kleros/web/dk-support-improvement
Support for Gated Dispute Kits and other improvements
2 parents 026fe83 + b5fff19 commit bff4f10

35 files changed

+880
-128
lines changed

subgraph/core/src/utils.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ export const ZERO = BigInt.fromI32(0);
44
export const ONE = BigInt.fromI32(1);
55

66
export function extractDisputeKitIDFromExtraData(extraData: Bytes): string {
7-
const start = extraData.length - 32;
8-
const littleEndian = extraData.subarray(start, extraData.length).reverse();
7+
const littleEndian = extraData.subarray(64, 96).reverse();
98
return BigInt.fromUnsignedBytes(Bytes.fromUint8Array(littleEndian)).toString();
109
}

subgraph/core/subgraph.template.yaml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,82 @@ dataSources:
160160
- event: CommitCast(indexed uint256,indexed address,uint256[],bytes32)
161161
handler: handleCommitCast
162162
file: ./src/DisputeKitClassic.ts
163+
- kind: ethereum
164+
name: DisputeKitGated
165+
network: _PLACEHOLDER_
166+
source:
167+
address: "_PLACEHOLDER_"
168+
abi: DisputeKitGated
169+
startBlock: _PLACEHOLDER_
170+
mapping:
171+
kind: ethereum/events
172+
apiVersion: 0.0.7
173+
language: wasm/assemblyscript
174+
entities:
175+
- ClassicDispute
176+
- ClassicRound
177+
- ClassicVote
178+
- ClassicContribution
179+
abis:
180+
- name: DisputeKitGated
181+
file: ../../contracts/deployments/_PLACEHOLDER_/DisputeKitGated.json
182+
- name: DisputeKitClassic # Required on Alchemy
183+
file: ../../contracts/deployments/_PLACEHOLDER_/DisputeKitClassic.json
184+
- name: KlerosCore
185+
# FIX: temporarily point to abi with event addition
186+
file: ./abi-migrations/KlerosCore.json
187+
eventHandlers:
188+
- event: DisputeCreation(indexed uint256,uint256,bytes)
189+
handler: handleDisputeCreation
190+
- event: Contribution(indexed uint256,indexed uint256,uint256,indexed address,uint256)
191+
handler: handleContributionEvent
192+
- event: Withdrawal(indexed uint256,indexed uint256,uint256,indexed address,uint256)
193+
handler: handleWithdrawal
194+
- event: ChoiceFunded(indexed uint256,indexed uint256,indexed uint256)
195+
handler: handleChoiceFunded
196+
- event: VoteCast(indexed uint256,indexed address,uint256[],indexed uint256,string)
197+
handler: handleVoteCast
198+
- event: CommitCast(indexed uint256,indexed address,uint256[],bytes32)
199+
handler: handleCommitCast
200+
file: ./src/DisputeKitClassic.ts
201+
- kind: ethereum
202+
name: DisputeKitGatedShutter
203+
network: _PLACEHOLDER_
204+
source:
205+
address: "_PLACEHOLDER_"
206+
abi: DisputeKitGatedShutter
207+
startBlock: _PLACEHOLDER_
208+
mapping:
209+
kind: ethereum/events
210+
apiVersion: 0.0.7
211+
language: wasm/assemblyscript
212+
entities:
213+
- ClassicDispute
214+
- ClassicRound
215+
- ClassicVote
216+
- ClassicContribution
217+
abis:
218+
- name: DisputeKitGatedShutter
219+
file: ../../contracts/deployments/_PLACEHOLDER_/DisputeKitGatedShutter.json
220+
- name: DisputeKitClassic # Required on Alchemy
221+
file: ../../contracts/deployments/_PLACEHOLDER_/DisputeKitClassic.json
222+
- name: KlerosCore
223+
# FIX: temporarily point to abi with event addition
224+
file: ./abi-migrations/KlerosCore.json
225+
eventHandlers:
226+
- event: DisputeCreation(indexed uint256,uint256,bytes)
227+
handler: handleDisputeCreation
228+
- event: Contribution(indexed uint256,indexed uint256,uint256,indexed address,uint256)
229+
handler: handleContributionEvent
230+
- event: Withdrawal(indexed uint256,indexed uint256,uint256,indexed address,uint256)
231+
handler: handleWithdrawal
232+
- event: ChoiceFunded(indexed uint256,indexed uint256,indexed uint256)
233+
handler: handleChoiceFunded
234+
- event: VoteCast(indexed uint256,indexed address,uint256[],indexed uint256,string)
235+
handler: handleVoteCast
236+
- event: CommitCast(indexed uint256,indexed address,uint256[],bytes32)
237+
handler: handleCommitCast
238+
file: ./src/DisputeKitClassic.ts
163239
- kind: ethereum
164240
name: EvidenceModule
165241
network: _PLACEHOLDER_

subgraph/core/subgraph.yaml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,82 @@ dataSources:
161161
- event: CommitCast(indexed uint256,indexed address,uint256[],bytes32)
162162
handler: handleCommitCast
163163
file: ./src/DisputeKitClassic.ts
164+
- kind: ethereum
165+
name: DisputeKitGated
166+
network: arbitrum-sepolia
167+
source:
168+
address: "0x677dA30B4b27D129354DdA1e219Bcc86802132d1"
169+
abi: DisputeKitGated
170+
startBlock: 175286139
171+
mapping:
172+
kind: ethereum/events
173+
apiVersion: 0.0.7
174+
language: wasm/assemblyscript
175+
entities:
176+
- ClassicDispute
177+
- ClassicRound
178+
- ClassicVote
179+
- ClassicContribution
180+
abis:
181+
- name: DisputeKitGated
182+
file: ../../contracts/deployments/arbitrumSepoliaDevnet/DisputeKitGated.json
183+
- name: DisputeKitClassic # Required on Alchemy
184+
file: ../../contracts/deployments/arbitrumSepoliaDevnet/DisputeKitClassic.json
185+
- name: KlerosCore
186+
# FIX: temporarily point to abi with event addition
187+
file: ./abi-migrations/KlerosCore.json
188+
eventHandlers:
189+
- event: DisputeCreation(indexed uint256,uint256,bytes)
190+
handler: handleDisputeCreation
191+
- event: Contribution(indexed uint256,indexed uint256,uint256,indexed address,uint256)
192+
handler: handleContributionEvent
193+
- event: Withdrawal(indexed uint256,indexed uint256,uint256,indexed address,uint256)
194+
handler: handleWithdrawal
195+
- event: ChoiceFunded(indexed uint256,indexed uint256,indexed uint256)
196+
handler: handleChoiceFunded
197+
- event: VoteCast(indexed uint256,indexed address,uint256[],indexed uint256,string)
198+
handler: handleVoteCast
199+
- event: CommitCast(indexed uint256,indexed address,uint256[],bytes32)
200+
handler: handleCommitCast
201+
file: ./src/DisputeKitClassic.ts
202+
- kind: ethereum
203+
name: DisputeKitGatedShutter
204+
network: arbitrum-sepolia
205+
source:
206+
address: "0xd86b84eb36Cd48f3f384b4490F255b494385F429"
207+
abi: DisputeKitGatedShutter
208+
startBlock: 175286153
209+
mapping:
210+
kind: ethereum/events
211+
apiVersion: 0.0.7
212+
language: wasm/assemblyscript
213+
entities:
214+
- ClassicDispute
215+
- ClassicRound
216+
- ClassicVote
217+
- ClassicContribution
218+
abis:
219+
- name: DisputeKitGatedShutter
220+
file: ../../contracts/deployments/arbitrumSepoliaDevnet/DisputeKitGatedShutter.json
221+
- name: DisputeKitClassic # Required on Alchemy
222+
file: ../../contracts/deployments/arbitrumSepoliaDevnet/DisputeKitClassic.json
223+
- name: KlerosCore
224+
# FIX: temporarily point to abi with event addition
225+
file: ./abi-migrations/KlerosCore.json
226+
eventHandlers:
227+
- event: DisputeCreation(indexed uint256,uint256,bytes)
228+
handler: handleDisputeCreation
229+
- event: Contribution(indexed uint256,indexed uint256,uint256,indexed address,uint256)
230+
handler: handleContributionEvent
231+
- event: Withdrawal(indexed uint256,indexed uint256,uint256,indexed address,uint256)
232+
handler: handleWithdrawal
233+
- event: ChoiceFunded(indexed uint256,indexed uint256,indexed uint256)
234+
handler: handleChoiceFunded
235+
- event: VoteCast(indexed uint256,indexed address,uint256[],indexed uint256,string)
236+
handler: handleVoteCast
237+
- event: CommitCast(indexed uint256,indexed address,uint256[],bytes32)
238+
handler: handleCommitCast
239+
file: ./src/DisputeKitClassic.ts
164240
- kind: ethereum
165241
name: EvidenceModule
166242
network: arbitrum-sepolia

subgraph/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@kleros/kleros-v2-subgraph",
3-
"version": "0.17.1",
3+
"version": "0.17.2",
44
"drtVersion": "0.13.0",
55
"license": "MIT",
66
"scripts": {

web/src/consts/index.ts

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,9 @@ export const RPC_ERROR = `RPC Error: Unable to fetch dispute data. Please avoid
4343

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

46-
export const getDisputeKitName = (id: number): string | undefined => {
47-
const universityDisputeKits: Record<number, string> = { 1: "Classic Dispute Kit" };
48-
const neoDisputeKits: Record<number, string> = { 1: "Classic Dispute Kit" };
49-
const testnetDisputeKits: Record<number, string> = { 1: "Classic Dispute Kit" };
50-
const devnetDisputeKits: Record<number, string> = { 1: "Classic Dispute Kit", 2: "Shutter Dispute Kit" };
51-
52-
if (isKlerosUniversity()) return universityDisputeKits[id];
53-
if (isKlerosNeo()) return neoDisputeKits[id];
54-
if (isTestnetDeployment()) return testnetDisputeKits[id];
55-
return devnetDisputeKits[id];
56-
};
46+
export enum DisputeKits {
47+
Classic = "Classic",
48+
Shutter = "Shutter",
49+
Gated = "Token Gated",
50+
GatedShutter = "Token Gated Shutter",
51+
}

web/src/context/NewDisputeContext.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,22 @@ interface IDisputeData extends IDisputeTemplate {
5151
arbitrationCost?: string;
5252
aliasesArray?: AliasArray[];
5353
disputeKitId?: number;
54+
disputeKitData?: IDisputeKitData;
55+
}
56+
57+
export type IDisputeKitData = IGatedDisputeData | ISomeFutureDisputeData;
58+
59+
export interface IGatedDisputeData {
60+
type: "gated";
61+
isERC1155: boolean;
62+
tokenGate: string;
63+
tokenId: string;
64+
}
65+
66+
// Placeholder
67+
export interface ISomeFutureDisputeData {
68+
type: "future";
69+
contract: string;
5470
}
5571

5672
interface INewDisputeContext {

web/src/hooks/queries/useDisputeDetailsQuery.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ const disputeDetailsQuery = graphql(`
3030
nbVotes
3131
disputeKit {
3232
id
33+
address
3334
}
3435
}
3536
currentRoundIndex

web/src/hooks/queries/useRoundDetailsQuery.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ const roundDetailsQuery = graphql(`
1717
disputeKit {
1818
id
1919
}
20+
dispute {
21+
disputeKitDispute {
22+
... on ClassicDispute {
23+
extraData
24+
}
25+
}
26+
}
2027
}
2128
}
2229
`);

web/src/hooks/queries/useSupportedDisputeKits.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { useQuery } from "@tanstack/react-query";
2+
23
import { useGraphqlBatcher } from "context/GraphqlBatcher";
4+
35
import { graphql } from "src/graphql";
46
import { SupportedDisputeKitsQuery } from "src/graphql/graphql";
57

@@ -8,6 +10,7 @@ const supportedDisputeKitsQuery = graphql(`
810
court(id: $id) {
911
supportedDisputeKits {
1012
id
13+
address
1114
}
1215
}
1316
}

0 commit comments

Comments
 (0)