Skip to content

Commit

Permalink
feat(subgraph): add blocknumber fields
Browse files Browse the repository at this point in the history
  • Loading branch information
alcercu committed Sep 13, 2023
1 parent 23c21d8 commit efe8852
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 1 deletion.
3 changes: 2 additions & 1 deletion subgraph/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ type Dispute @entity {
tied: Boolean!
overridden: Boolean!
lastPeriodChange: BigInt!
lastPeriodChangeBlockNumber: BigInt!
rounds: [Round!]! @derivedFrom(field: "dispute")
currentRound: Round!
currentRoundIndex: BigInt!
Expand All @@ -169,9 +170,9 @@ type Round @entity {
feeToken: FeeToken
}

type Draw @entity {
type Draw @entity(immutable: true) {
id: ID! # dispute.id-currentRound-voteID
blockNumber: BigInt!
dispute: Dispute!
round: Round!
juror: User!
Expand Down
1 change: 1 addition & 0 deletions subgraph/src/KlerosCore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ export function handleNewPeriod(event: NewPeriod): void {

dispute.period = newPeriod;
dispute.lastPeriodChange = event.block.timestamp;
dispute.lastPeriodChangeBlockNumber = event.block.number;
dispute.save();
court.save();
}
Expand Down
1 change: 1 addition & 0 deletions subgraph/src/entities/Dispute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export function createDisputeFromEvent(event: DisputeCreation): void {
dispute.tied = true;
dispute.overridden = false;
dispute.lastPeriodChange = event.block.timestamp;
dispute.lastPeriodChangeBlockNumber = event.block.number;
dispute.currentRoundIndex = ZERO;
const roundID = `${disputeID.toString()}-${ZERO.toString()}`;
dispute.currentRound = roundID;
Expand Down
1 change: 1 addition & 0 deletions subgraph/src/entities/Draw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export function createDrawFromEvent(event: DrawEvent): void {
const voteID = event.params._voteID;
const drawID = `${disputeID}-${roundIndex.toString()}-${voteID.toString()}`;
const draw = new Draw(drawID);
draw.blockNumber = event.block.number;
draw.dispute = disputeID;
draw.round = roundID;
draw.juror = event.params._address.toHexString();
Expand Down

0 comments on commit efe8852

Please sign in to comment.