Skip to content

Commit 7cd9019

Browse files
committed
save contributors inside DisputeEntity
1 parent 7e2db66 commit 7cd9019

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

schema.graphql

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ type DisputeEntity @entity {
4444
lastPeriodChange: BigInt
4545
court: CourtEntity!
4646
rounds: [RoundEntity!]! @derivedFrom(field: "dispute")
47+
contributors: [User!]!
4748
}
4849

4950
type RoundEntity @entity {

src/TruthPost.ts

+11-3
Original file line numberDiff line numberDiff line change
@@ -227,11 +227,19 @@ export function handleEvidence(event: Evidence): void {
227227
}
228228

229229
export function handleContribution(event: Contribution): void {
230-
/* let article = getArticleEntityInstance(event.params.disputeId);
231-
232-
getPopulatedEventEntity(event, "ClaimWithdrawal", article.id, event.transaction.value.toString()).save(); */
230+
// let x: string[] = [];
233231

234232
const disputeID = event.params.disputeId;
233+
let disputeEntity = DisputeEntity.load(disputeID.toString());
234+
if(!disputeEntity) return;
235+
let article = getArticleEntityInstance(BigInt.fromString(disputeEntity.article.split("-")[0]));
236+
const rawMessage = `${event.params.ruling}-${event.params.amount}-${event.params.contributor}`
237+
getPopulatedEventEntity(event, "Contribution", article.id, rawMessage).save();
238+
239+
disputeEntity.contributors = disputeEntity.contributors || new Array<string>();
240+
disputeEntity.contributors.push(event.params.contributor.toString());
241+
disputeEntity.save();
242+
235243

236244
const lastRoundIndex = event.params.round;
237245
const roundID = `${disputeID.toString()}-${lastRoundIndex.toString()}`;

0 commit comments

Comments
 (0)