Skip to content
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
238 changes: 167 additions & 71 deletions subgraph/schema.graphql
Original file line number Diff line number Diff line change
@@ -1,126 +1,157 @@
#########
# Enums #
#########

enum Period {
Evidence
Commit
Vote
Appeal
Execution
evidence
commit
vote
appeal
execution
}

type Court @entity {
##############
# Interfaces #
##############

interface DisputeKitDispute {
id: ID!
policy: String
hiddenVotes: Boolean!
parent: Court
children: [Court!]! @derivedFrom(field: "parent")
minStake: BigInt!
alpha: BigInt!
feeForJuror: BigInt!
jurorsForCourtJump: BigInt!
timesPerPeriod: [BigInt!]!
supportedDisputeKits: [DisputeKit!]!
disputes: [Dispute!]! @derivedFrom(field: "courtID")
numberDisputes: BigInt!
stakedJurors: [JurorTokensPerCourt!]! @derivedFrom(field: "court")
numberStakedJurors: BigInt!
tokens: [JurorTokensPerCourt!]! @derivedFrom(field: "court")
stake: BigInt!
paidETH: BigInt!
paidPNK: BigInt!
coreDispute: Dispute!
localRounds: [DisputeKitRound!]! @derivedFrom(field: "localDispute")
currentLocalRoundIndex: BigInt!
}

interface DisputeKitRound {
id: ID!
localDispute: DisputeKitDispute!
}

interface Vote {
id: ID!
coreDispute: Dispute!
localRound: DisputeKitRound!
juror: User!
}

interface Contribution {
id: ID!
coreDispute: Dispute!
contributor: User!
}

type Juror @entity {
id: ID! # Set to address
interface EvidenceGroup {
id: ID!
evidences: [Evidence!]! @derivedFrom(field: "evidenceGroup")
nextEvidenceIndex: BigInt!
}

interface Evidence {
id: ID!
evidence: String!
evidenceGroup: EvidenceGroup!
sender: User!
}

############
# Entities #
############

type User @entity {
id: ID! # address
tokens: [JurorTokensPerCourt!]! @derivedFrom(field: "juror")
totalStake: BigInt!
shifts: [TokenAndETHShift!]! @derivedFrom(field: "juror")
draws: [Draw!]! @derivedFrom(field: "juror")
votes: [Vote!]! @derivedFrom(field: "juror")
contributions: [Contribution!]! @derivedFrom(field: "contributor")
evidences: [Evidence!]! @derivedFrom(field: "sender")
}

type Arbitrated @entity {
id: ID! # address
disputes: [Dispute!]! @derivedFrom(field: "arbitrated")
totalDisputes: BigInt!
}

type TokenAndETHShift @entity {
id: ID! # Set to `${juror.id}-${dispute.id}`
juror: Juror!
id: ID! # user.id-dispute.id
juror: User!
dispute: Dispute!
tokenAmount: BigInt!
ethAmount: BigInt!
}

type JurorTokensPerCourt @entity {
id: ID! # Set to `${juror.id}-${court.id}`
juror: Juror!
id: ID! # user.id-court.id
juror: User!
court: Court!
staked: BigInt!
locked: BigInt!
}

type EvidenceGroup @entity {
type Court @entity {
id: ID!
evidences: [Evidence!]! @derivedFrom(field: "evidenceGroup")
lastEvidenceID: BigInt!
parent: Court
hiddenVotes: Boolean!
children: [Court!]! @derivedFrom(field: "parent")
minStake: BigInt!
alpha: BigInt!
feeForJuror: BigInt!
jurorsForCourtJump: BigInt!
timesPerPeriod: [BigInt!]!
supportedDisputeKits: [DisputeKit!]!
disputes: [Dispute!]! @derivedFrom(field: "court")
numberDisputes: BigInt!
stakedJurors: [JurorTokensPerCourt!]! @derivedFrom(field: "court")
numberStakedJurors: BigInt!
stake: BigInt!
paidETH: BigInt!
paidPNK: BigInt!
policy: String
}

type Evidence @entity {
id: ID! # Set to `${evidenceGroupID}-${id}`
evidence: String!
evidenceGroup: EvidenceGroup!
sender: Bytes!
type Dispute @entity {
id: ID!
court: Court!
arbitrated: Arbitrated!
period: Period!
ruled: Boolean!
lastPeriodChange: BigInt!
rounds: [Round!]! @derivedFrom(field: "dispute")
currentRound: Round!
currentRoundIndex: BigInt!
shifts: [TokenAndETHShift!]! @derivedFrom(field: "dispute")
disputeKitDispute: DisputeKitDispute @derivedFrom(field: "coreDispute")
}

type Round @entity {
id: ID! # Set to `${dispute.id}-${currentRound}`
dispute: Dispute!
disputeKitID: DisputeKit!
id: ID! # dispute.id-dispute.rounds.length
disputeKit: DisputeKit!
tokensAtStakePerJuror: BigInt!
totalFeesForJurors: BigInt!
nbVotes: BigInt!
totalVoted: BigInt!
repartitions: BigInt!
penalties: BigInt!
drawnJurors: [Draw!]! @derivedFrom(field: "round")
votes: [Vote!]! @derivedFrom(field: "round")
currentDecision: BigInt
}

type Vote @entity {
id: ID! # Set to `${coreDisputeID}-${coreRoundID}-${jurorAddress}`
dispute: Dispute!
round: Round!
juror: Juror!
choice: BigInt
justification: String
}

type Draw @entity {
id: ID! # Set to `${dispute.id}-${currentRound}-${voteID}`
id: ID! # dispute.id-currentRound-voteID
dispute: Dispute!
round: Round!
juror: Juror!
juror: User!
voteID: BigInt!
}

type Dispute @entity {
id: ID!
courtID: Court!
arbitrated: Bytes!
period: Period!
ruled: Boolean!
lastPeriodChange: BigInt!
rounds: [Round!]! @derivedFrom(field: "dispute")
draws: [Draw!]! @derivedFrom(field: "dispute")
votes: [Vote!]! @derivedFrom(field: "dispute")
currentRound: Int!
shifts: [TokenAndETHShift!]! @derivedFrom(field: "dispute")
gatewayDispute: GatewayDispute! @derivedFrom(field: "homeDispute")
}

type DisputeKit @entity {
id: ID!
address: Bytes
parent: DisputeKit
children: [DisputeKit!]! @derivedFrom(field: "parent")
needsFreezing: Boolean!
depthLevel: BigInt!
rounds: [Round!]! @derivedFrom(field: "disputeKitID")
rounds: [Round!]! @derivedFrom(field: "disputeKit")
courts: [Court!]! @derivedFrom(field: "supportedDisputeKits")
}

Expand All @@ -134,7 +165,7 @@ type GatewayDispute @entity {
}

type OutgoingBatch @entity {
id: ID! # Set to messageHash
id: ID! # messageHash
size: BigInt!
epoch: BigInt!
batchMerkleRoot: String!
Expand All @@ -150,3 +181,68 @@ type Counter @entity {
casesVoting: BigInt!
casesRuled: BigInt!
}

#####################
# ClassicDisputeKit #
#####################

type ClassicDispute implements DisputeKitDispute @entity {
id: ID! # disputeKit.id-coreDispute
coreDispute: Dispute!
localRounds: [DisputeKitRound!]! @derivedFrom(field: "localDispute")
currentLocalRoundIndex: BigInt!

numberOfChoices: BigInt!
jumped: Boolean!
extraData: Bytes!
}

type ClassicRound implements DisputeKitRound @entity {
id: ID! # disputeKit.id-coreDispute-dispute.rounds.length
localDispute: DisputeKitDispute!

votes: [ClassicVote!]!
winningChoice: BigInt!
counts: [BigInt!]!
tied: Boolean!
totalVoted: BigInt!
totalCommited: BigInt!
paidFees: [BigInt!]!
contributions: [ClassicContribution!]! @derivedFrom(field: "localRound")
feeRewards: BigInt!
fundedChoices: [BigInt!]!
}

type ClassicVote implements Vote @entity {
id: ID! # disputeKit.id-coreDispute-currentRound-juror
coreDispute: Dispute!
localRound: DisputeKitRound!
juror: User!

choice: BigInt!
justification: String!
}

type ClassicEvidenceGroup implements EvidenceGroup @entity {
id: ID!
evidences: [Evidence!]! @derivedFrom(field: "evidenceGroup")
nextEvidenceIndex: BigInt!
}

type ClassicEvidence implements Evidence @entity {
id: ID! # classicEvidenceGroup.id-nextEvidenceIndex
evidence: String!
evidenceGroup: EvidenceGroup!
sender: User!
}

type ClassicContribution implements Contribution @entity {
id: ID! # disputeKit.id-dispute.id-classicround.id-contributor-choice
contributor: User!
coreDispute: Dispute!

localRound: ClassicRound!
amount: BigInt!
choice: BigInt!
rewardWithdrawn: Boolean!
}
Loading