Skip to content

Commit

Permalink
chore: expand subgraph
Browse files Browse the repository at this point in the history
  • Loading branch information
epiqueras committed Sep 11, 2020
1 parent 5c048fb commit 788c53f
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 13 deletions.
10 changes: 5 additions & 5 deletions subgraph/schema.graphql
Expand Up @@ -246,7 +246,7 @@ type Evidence @entity {
"""
request: Request!
"""
The evidence's ID, keccak256(requestID, requestEvidenceLength).
The evidence's ID, keccak256(requestID, "Evidence-" + requestEvidenceLength).
"""
id: ID!
"""
Expand All @@ -265,17 +265,17 @@ type Challenge @entity {
"""
request: Request!
"""
The challenge's ID, keccak256(requestID, requestChallengesLength).
The challenge's ID, keccak256(requestID, "Challenge-" + requestChallengesLength).
"""
id: ID!
"""
The challenge's dispute ID.
"""
disputeID: BigInt!
disputeID: BigInt
"""
The address of the challenger.
"""
challenger: Bytes!
challenger: Bytes
"""
The submission which is a supposed duplicate of the challenged submission. This is only used for `Reason.Duplicate`.
"""
Expand Down Expand Up @@ -306,7 +306,7 @@ type Round @entity {
"""
True for a side when it has fully paid its fee. False otherwise.
"""
hasPaid: [BigInt!]!
hasPaid: [Boolean!]!
"""
Sum of reimbursable fees and stake rewards available to the parties that made contributions to the side that ultimately won.
"""
Expand Down
36 changes: 28 additions & 8 deletions subgraph/src/mapping.ts
@@ -1,16 +1,18 @@
import { ByteArray, BigInt, crypto } from "@graphprotocol/graph-ts";
import { BigInt, ByteArray, crypto } from "@graphprotocol/graph-ts";
import {
ProofOfHumanity as _ProofOfHumanity,
MetaEvidence as MetaEvidenceEvent,
ArbitratorComplete,
AddSubmissionManuallyCall,
ArbitratorComplete,
MetaEvidence as MetaEvidenceEvent,
ProofOfHumanity as _ProofOfHumanity,
} from "../generated/ProofOfHumanity/ProofOfHumanity";
import {
MetaEvidence,
Challenge,
Contract,
Submission,
Request,
Evidence,
MetaEvidence,
Request,
Round,
Submission,
} from "../generated/schema";

function concatByteArrays(a: ByteArray, b: ByteArray): ByteArray {
Expand Down Expand Up @@ -95,11 +97,29 @@ export function addSubmissionManually(call: AddSubmissionManuallyCall): void {

let evidence = new Evidence(
crypto
.keccak256(concatByteArrays(requestID, ByteArray.fromUTF8("0")))
.keccak256(concatByteArrays(requestID, ByteArray.fromUTF8("Evidence-0")))
.toHexString()
);
evidence.request = request.id;
evidence.URI = call.inputs._evidence;
evidence.sender = call.from;
evidence.save();

let challengeID = crypto.keccak256(
concatByteArrays(requestID, ByteArray.fromUTF8("Challenge-0"))
);
let challenge = new Challenge(challengeID.toHexString());
challenge.request = request.id;
challenge.save();

let round = new Round(
crypto
.keccak256(concatByteArrays(challengeID, ByteArray.fromUTF8("0")))
.toHexString()
);
round.challenge = challenge.id;
round.paidFees = [new BigInt(0), new BigInt(0)];
round.hasPaid = [false, false];
round.feeRewards = new BigInt(0);
round.save();
}

0 comments on commit 788c53f

Please sign in to comment.