Better schema

This commit is contained in:
Tornado Contrib 2024-04-28 05:50:14 +00:00
parent d50b759ebe
commit 7758422952
Signed by: tornadocontrib
GPG Key ID: 60B4DF1A076C64B1
2 changed files with 28 additions and 28 deletions

@ -14,7 +14,7 @@ type Proposal @entity {
executed: Boolean!
}
type Voted @entity {
type Vote @entity {
id: ID!
timestamp: Int!
blockNumber: Int!
@ -29,7 +29,7 @@ type Voted @entity {
input: Bytes!
}
type Delegated @entity {
type Delegate @entity {
id: ID!
timestamp: Int!
blockNumber: Int!
@ -40,7 +40,7 @@ type Delegated @entity {
delegateTo: Bytes!
}
type Undelegated @entity {
type Undelegate @entity {
id: ID!
timestamp: Int!
blockNumber: Int!
@ -51,7 +51,7 @@ type Undelegated @entity {
delegateFrom: Bytes!
}
type StakeBurned @entity {
type StakeBurn @entity {
id: ID!
timestamp: Int!
blockNumber: Int!
@ -62,7 +62,7 @@ type StakeBurned @entity {
amountBurned: BigInt!
}
type StakeDailyBurned @entity {
type StakeDailyBurn @entity {
id: ID!
date: Int!
dailyAmountBurned: BigInt!

@ -1,21 +1,21 @@
import { BigInt } from "@graphprotocol/graph-ts";
import {
Proposal,
Voted,
Delegated,
Undelegated,
StakeBurned,
StakeDailyBurned,
Vote,
Delegate,
Undelegate,
StakeBurn,
StakeDailyBurn,
} from "../generated/schema";
import {
ProposalCreated,
ProposalExecuted,
Voted as VotedEvent,
Delegated as DelegatedEvent,
Undelegated as UndelegatedEvent,
Voted,
Delegated,
Undelegated,
} from "../generated/Governance/Governance";
import {
StakeBurned as StakeBurnedEvent
StakeBurned
} from "../generated/RelayerRegistry/RelayerRegistry";
export let ZERO_BI = BigInt.fromI32(0);
@ -50,11 +50,11 @@ export function handleProposalExecuted(event: ProposalExecuted): void {
}
}
export function handleVoted(event: VotedEvent): void {
let voted = Voted.load(event.transaction.hash.toHex() + '_' + event.logIndex.toString());
export function handleVoted(event: Voted): void {
let voted = Vote.load(event.transaction.hash.toHex() + '_' + event.logIndex.toString());
if (voted === null) {
voted = new Voted(event.transaction.hash.toHex() + '_' + event.logIndex.toString());
voted = new Vote(event.transaction.hash.toHex() + '_' + event.logIndex.toString());
voted.timestamp = event.block.timestamp.toI32();
voted.blockNumber = event.block.number.toI32();
voted.logIndex = event.logIndex.toI32();
@ -70,11 +70,11 @@ export function handleVoted(event: VotedEvent): void {
}
}
export function handleDelegated(event: DelegatedEvent): void {
let delegated = Delegated.load(event.transaction.hash.toHex() + '_' + event.logIndex.toString());
export function handleDelegated(event: Delegated): void {
let delegated = Delegate.load(event.transaction.hash.toHex() + '_' + event.logIndex.toString());
if (delegated === null) {
delegated = new Delegated(event.transaction.hash.toHex() + '_' + event.logIndex.toString());
delegated = new Delegate(event.transaction.hash.toHex() + '_' + event.logIndex.toString());
delegated.timestamp = event.block.timestamp.toI32();
delegated.blockNumber = event.block.number.toI32();
delegated.logIndex = event.logIndex.toI32();
@ -86,11 +86,11 @@ export function handleDelegated(event: DelegatedEvent): void {
}
}
export function handleUndelegated(event: UndelegatedEvent): void {
let undelegated = Undelegated.load(event.transaction.hash.toHex() + '_' + event.logIndex.toString());
export function handleUndelegated(event: Undelegated): void {
let undelegated = Undelegate.load(event.transaction.hash.toHex() + '_' + event.logIndex.toString());
if (undelegated === null) {
undelegated = new Undelegated(event.transaction.hash.toHex() + '_' + event.logIndex.toString());
undelegated = new Undelegate(event.transaction.hash.toHex() + '_' + event.logIndex.toString());
undelegated.timestamp = event.block.timestamp.toI32();
undelegated.blockNumber = event.block.number.toI32();
undelegated.logIndex = event.logIndex.toI32();
@ -102,11 +102,11 @@ export function handleUndelegated(event: UndelegatedEvent): void {
}
}
export function handleStakeBurned(event: StakeBurnedEvent): void {
let stakeBurned = StakeBurned.load(event.transaction.hash.toHex() + '_' + event.logIndex.toString());
export function handleStakeBurned(event: StakeBurned): void {
let stakeBurned = StakeBurn.load(event.transaction.hash.toHex() + '_' + event.logIndex.toString());
if (stakeBurned === null) {
stakeBurned = new StakeBurned(event.transaction.hash.toHex() + '_' + event.logIndex.toString());
stakeBurned = new StakeBurn(event.transaction.hash.toHex() + '_' + event.logIndex.toString());
stakeBurned.timestamp = event.block.timestamp.toI32();
stakeBurned.blockNumber = event.block.number.toI32();
stakeBurned.logIndex = event.logIndex.toI32();
@ -120,10 +120,10 @@ export function handleStakeBurned(event: StakeBurnedEvent): void {
let dayID = timestamp / 86400;
let dayStartTimestamp = dayID * 86400;
let dailyBurned = StakeDailyBurned.load(dayStartTimestamp.toString());
let dailyBurned = StakeDailyBurn.load(dayStartTimestamp.toString());
if (dailyBurned === null) {
dailyBurned = new StakeDailyBurned(dayStartTimestamp.toString());
dailyBurned = new StakeDailyBurn(dayStartTimestamp.toString());
dailyBurned.date = dayStartTimestamp;
dailyBurned.dailyAmountBurned = ZERO_BI;
}