From 7758422952ba47294664eaa4cda9b54fce584242 Mon Sep 17 00:00:00 2001 From: Tornado Contrib Date: Sun, 28 Apr 2024 05:50:14 +0000 Subject: [PATCH] Better schema --- schema.graphql | 10 +++++----- src/mapping.ts | 46 +++++++++++++++++++++++----------------------- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/schema.graphql b/schema.graphql index b4d52b6..e33e0af 100644 --- a/schema.graphql +++ b/schema.graphql @@ -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! diff --git a/src/mapping.ts b/src/mapping.ts index ca28c00..1c784b6 100644 --- a/src/mapping.ts +++ b/src/mapping.ts @@ -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; }