Skip to content

Commit 8429920

Browse files
committed
feat(subgraph): map DisputeKitClassic using interfaces
1 parent b2c609f commit 8429920

File tree

13 files changed

+440
-240
lines changed

13 files changed

+440
-240
lines changed

subgraph/schema.graphql

Lines changed: 153 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
#########
2+
# Enums #
3+
#########
4+
15
enum Period {
26
evidence
37
commit
@@ -6,6 +10,85 @@ enum Period {
610
execution
711
}
812

13+
##############
14+
# Interfaces #
15+
##############
16+
17+
interface DisputeKitDispute {
18+
id: ID!
19+
coreDispute: Dispute!
20+
localRounds: [DisputeKitRound!]! @derivedFrom(field: "localDispute")
21+
currentLocalRoundIndex: BigInt!
22+
}
23+
24+
interface DisputeKitRound {
25+
id: ID!
26+
localDispute: DisputeKitDispute!
27+
}
28+
29+
interface Vote {
30+
id: ID!
31+
coreDispute: Dispute!
32+
localRound: DisputeKitRound!
33+
juror: User!
34+
}
35+
36+
interface Contribution {
37+
id: ID!
38+
coreDispute: Dispute!
39+
contributor: User!
40+
}
41+
42+
interface EvidenceGroup {
43+
id: ID!
44+
evidences: [Evidence!]! @derivedFrom(field: "evidenceGroup")
45+
nextEvidenceIndex: BigInt!
46+
}
47+
48+
interface Evidence {
49+
id: ID!
50+
evidence: String!
51+
evidenceGroup: EvidenceGroup!
52+
sender: User!
53+
}
54+
55+
############
56+
# Entities #
57+
############
58+
59+
type User @entity {
60+
id: ID! # address
61+
tokens: [JurorTokensPerCourt!]! @derivedFrom(field: "juror")
62+
totalStake: BigInt!
63+
shifts: [TokenAndETHShift!]! @derivedFrom(field: "juror")
64+
draws: [Draw!]! @derivedFrom(field: "juror")
65+
votes: [Vote!]! @derivedFrom(field: "juror")
66+
contributions: [Contribution!]! @derivedFrom(field: "contributor")
67+
evidences: [Evidence!]! @derivedFrom(field: "sender")
68+
}
69+
70+
type Arbitrated @entity {
71+
id: ID! # address
72+
disputes: [Dispute!]! @derivedFrom(field: "arbitrated")
73+
totalDisputes: BigInt!
74+
}
75+
76+
type TokenAndETHShift @entity {
77+
id: ID! # user.id-dispute.id
78+
juror: User!
79+
dispute: Dispute!
80+
tokenAmount: BigInt!
81+
ethAmount: BigInt!
82+
}
83+
84+
type JurorTokensPerCourt @entity {
85+
id: ID! # user.id-court.id
86+
juror: User!
87+
court: Court!
88+
staked: BigInt!
89+
locked: BigInt!
90+
}
91+
992
type Court @entity {
1093
id: ID!
1194
parent: Court
@@ -30,7 +113,7 @@ type Court @entity {
30113
type Dispute @entity {
31114
id: ID!
32115
court: Court!
33-
arbitrated: Bytes!
116+
arbitrated: Arbitrated!
34117
period: Period!
35118
ruled: Boolean!
36119
lastPeriodChange: BigInt!
@@ -42,7 +125,7 @@ type Dispute @entity {
42125
}
43126

44127
type Round @entity {
45-
id: ID! # Set to `${dispute.id}-${dispute.rounds.length}`
128+
id: ID! # dispute.id-dispute.rounds.length
46129
disputeKit: DisputeKit!
47130
tokensAtStakePerJuror: BigInt!
48131
totalFeesForJurors: BigInt!
@@ -53,102 +136,11 @@ type Round @entity {
53136
dispute: Dispute!
54137
}
55138

56-
interface DisputeKitRound {
57-
id: ID! # Set to `${disputeKit.id}-{dispute.id}-{dispute.rounds.length}`
58-
}
59-
60-
type ClassicRound implements DisputeKitRound @entity {
61-
id: ID! # Set to `${disputeKit.id}-{dispute.id}-{dispute.rounds.length}`
62-
votes: [ClassicVote!]!
63-
winningChoice: BigInt!
64-
counts: [BigInt!]!
65-
tied: Boolean!
66-
totalVoted: BigInt!
67-
totalCommited: BigInt!
68-
paidFees: [BigInt!]!
69-
contributions: [Contribution!]! @derivedFrom(field: "round")
70-
feeRewards: BigInt!
71-
nbVotes: BigInt!
72-
}
73-
74-
type Contribution @entity {
75-
id: ID! # Set to `${dispute.id}-${round.id}-${contributor}-${choice}`
76-
contributor: Bytes!
77-
amount: BigInt!
78-
choice: BigInt!
79-
round: ClassicRound!
80-
}
81-
82-
type ClassicVote @entity {
83-
id: ID!
84-
}
85-
86-
interface DisputeKitDispute {
87-
id: ID! # Set to ${disputeKit.id}-{disputeKit.disputes.length}
88-
coreDispute: Dispute!
89-
}
90-
91-
type ClassicDispute implements DisputeKitDispute @entity {
92-
id: ID! # Set to ${disputeKit.id}-{disputeKit.disputes.length}
93-
coreDispute: Dispute!
94-
95-
numberOfChoices: BigInt!
96-
jumped: Boolean!
97-
extraData: Bytes!
98-
}
99-
100-
type Juror @entity {
101-
id: ID! # Set to address
102-
tokens: [JurorTokensPerCourt!]! @derivedFrom(field: "juror")
103-
totalStake: BigInt!
104-
shifts: [TokenAndETHShift!]! @derivedFrom(field: "juror")
105-
draws: [Draw!]! @derivedFrom(field: "juror")
106-
votes: [Vote!]! @derivedFrom(field: "juror")
107-
}
108-
109-
type TokenAndETHShift @entity {
110-
id: ID! # Set to `${juror.id}-${dispute.id}`
111-
juror: Juror!
112-
dispute: Dispute!
113-
tokenAmount: BigInt!
114-
ethAmount: BigInt!
115-
}
116-
117-
type JurorTokensPerCourt @entity {
118-
id: ID! # Set to `${juror.id}-${court.id}`
119-
juror: Juror!
120-
court: Court!
121-
staked: BigInt!
122-
locked: BigInt!
123-
}
124-
125-
type EvidenceGroup @entity {
126-
id: ID!
127-
evidences: [Evidence!]! @derivedFrom(field: "evidenceGroup")
128-
lastEvidenceID: BigInt!
129-
}
130-
131-
type Evidence @entity {
132-
id: ID! # Set to `${evidenceGroupID}-${id}`
133-
evidence: String!
134-
evidenceGroup: EvidenceGroup!
135-
sender: Bytes!
136-
}
137-
138-
type Vote @entity {
139-
id: ID! # Set to `${coreDisputeID}-${coreRoundID}-${jurorAddress}`
140-
dispute: Dispute!
141-
round: Round!
142-
juror: Juror!
143-
choice: BigInt
144-
justification: String
145-
}
146-
147139
type Draw @entity {
148-
id: ID! # Set to `${dispute.id}-${currentRound}-${voteID}`
140+
id: ID! # dispute.id-currentRound-voteID
149141
dispute: Dispute!
150142
round: Round!
151-
juror: Juror!
143+
juror: User!
152144
voteID: BigInt!
153145
}
154146

@@ -173,7 +165,7 @@ type GatewayDispute @entity {
173165
}
174166

175167
type OutgoingBatch @entity {
176-
id: ID! # Set to messageHash
168+
id: ID! # messageHash
177169
size: BigInt!
178170
epoch: BigInt!
179171
batchMerkleRoot: String!
@@ -189,3 +181,68 @@ type Counter @entity {
189181
casesVoting: BigInt!
190182
casesRuled: BigInt!
191183
}
184+
185+
#####################
186+
# ClassicDisputeKit #
187+
#####################
188+
189+
type ClassicDispute implements DisputeKitDispute @entity {
190+
id: ID! # disputeKit.id-coreDispute
191+
coreDispute: Dispute!
192+
localRounds: [DisputeKitRound!]! @derivedFrom(field: "localDispute")
193+
currentLocalRoundIndex: BigInt!
194+
195+
numberOfChoices: BigInt!
196+
jumped: Boolean!
197+
extraData: Bytes!
198+
}
199+
200+
type ClassicRound implements DisputeKitRound @entity {
201+
id: ID! # disputeKit.id-coreDispute-dispute.rounds.length
202+
localDispute: DisputeKitDispute!
203+
204+
votes: [ClassicVote!]!
205+
winningChoice: BigInt!
206+
counts: [BigInt!]!
207+
tied: Boolean!
208+
totalVoted: BigInt!
209+
totalCommited: BigInt!
210+
paidFees: [BigInt!]!
211+
contributions: [ClassicContribution!]! @derivedFrom(field: "localRound")
212+
feeRewards: BigInt!
213+
fundedChoices: [BigInt!]!
214+
}
215+
216+
type ClassicVote implements Vote @entity {
217+
id: ID! # disputeKit.id-coreDispute-currentRound-juror
218+
coreDispute: Dispute!
219+
localRound: DisputeKitRound!
220+
juror: User!
221+
222+
choice: BigInt!
223+
justification: String!
224+
}
225+
226+
type ClassicEvidenceGroup implements EvidenceGroup @entity {
227+
id: ID!
228+
evidences: [Evidence!]! @derivedFrom(field: "evidenceGroup")
229+
nextEvidenceIndex: BigInt!
230+
}
231+
232+
type ClassicEvidence implements Evidence @entity {
233+
id: ID! # classicEvidenceGroup.id-nextEvidenceIndex
234+
evidence: String!
235+
evidenceGroup: EvidenceGroup!
236+
sender: User!
237+
}
238+
239+
type ClassicContribution implements Contribution @entity {
240+
id: ID! # disputeKit.id-dispute.id-classicround.id-contributor-choice
241+
contributor: User!
242+
coreDispute: Dispute!
243+
244+
localRound: ClassicRound!
245+
amount: BigInt!
246+
choice: BigInt!
247+
rewardWithdrawn: Boolean!
248+
}

0 commit comments

Comments
 (0)