Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
chore: update subgraph notification schema
  • Loading branch information
shotaronowhere committed Oct 17, 2023
commit 8c48d81b24c83313dbe314753c1020400848de0a
3 changes: 1 addition & 2 deletions subgraph/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ type Dispute @entity {
periodDeadline: BigInt! # uint256j
periodNotificationIndex: BigInt!
lastPeriodChangeTs: BigInt!
users: [User!]!
lastPeriodChangeBlock: BigInt!
lastPeriodChangeBlockNumber: BigInt!
rounds: [Round!]! @derivedFrom(field: "dispute")
Expand Down Expand Up @@ -193,7 +192,7 @@ type Draw @entity(immutable: true) {
dispute: Dispute!
round: Round!
juror: User!
voteID: BigInt!
voteIDNum: BigInt!
vote: Vote @derivedFrom(field: "draw")
drawNotificationIndex: BigInt
}
Expand Down
7 changes: 3 additions & 4 deletions subgraph/src/KlerosCore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,13 @@ export function handleNewPeriod(event: NewPeriod): void {
counter.counter = BigInt.fromI32(0);
}
dispute.periodNotificationIndex = counter.counter;
const contract = KlerosCore.bind(event.address);
const courtContractState = contract.getTimesPerPeriod(BigInt.fromString(dispute.court));
dispute.periodDeadline = event.block.timestamp.plus(courtContractState[event.params._period]);
counter.counter = counter.counter.plus(ONE);
counter.save();
dispute.lastPeriodChangeBlockNumber = event.block.number;
if (newPeriod !== "execution") {
dispute.periodDeadline = event.block.timestamp.plus(court.timesPerPeriod[event.params._period]);
const contract = KlerosCore.bind(event.address);
const courtContractState = contract.getTimesPerPeriod(BigInt.fromString(dispute.court));
dispute.periodDeadline = event.block.timestamp.plus(courtContractState[event.params._period]);
} else {
dispute.periodDeadline = BigInt.fromU64(U64.MAX_VALUE);
}
Expand Down
1 change: 0 additions & 1 deletion subgraph/src/entities/Dispute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export function createDisputeFromEvent(event: DisputeCreation): void {
dispute.currentRuling = ZERO;
dispute.tied = true;
dispute.overridden = false;
dispute.users = [];
dispute.lastPeriodChangeTs = event.block.timestamp;
dispute.lastPeriodChangeBlock = event.block.timestamp;
dispute.lastPeriodChangeBlockNumber = event.block.number;
Expand Down
2 changes: 1 addition & 1 deletion subgraph/src/entities/Draw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ export function createDrawFromEvent(event: DrawEvent): void {
draw.dispute = disputeID;
draw.round = roundID;
draw.juror = event.params._address.toHexString();
draw.voteID = voteID;
draw.voteIDNum = voteID;
draw.save();
}
9 changes: 0 additions & 9 deletions subgraph/src/entities/User.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,6 @@ export function addUserActiveDispute(id: string, disputeID: string): void {
return;
}
user.disputes = user.disputes.concat([disputeID]);
const dispute = Dispute.load(disputeID);
if (!dispute) {
log.error("Dispute {} not found", [disputeID]);
return;
} else {
dispute.users.push(id);
dispute.save();
}

user.activeDisputes = user.activeDisputes.plus(ONE);
user.totalDisputes = user.totalDisputes.plus(ONE);
user.save();
Expand Down