Better schema
This commit is contained in:
parent
d50b759ebe
commit
7758422952
@ -14,7 +14,7 @@ type Proposal @entity {
|
|||||||
executed: Boolean!
|
executed: Boolean!
|
||||||
}
|
}
|
||||||
|
|
||||||
type Voted @entity {
|
type Vote @entity {
|
||||||
id: ID!
|
id: ID!
|
||||||
timestamp: Int!
|
timestamp: Int!
|
||||||
blockNumber: Int!
|
blockNumber: Int!
|
||||||
@ -29,7 +29,7 @@ type Voted @entity {
|
|||||||
input: Bytes!
|
input: Bytes!
|
||||||
}
|
}
|
||||||
|
|
||||||
type Delegated @entity {
|
type Delegate @entity {
|
||||||
id: ID!
|
id: ID!
|
||||||
timestamp: Int!
|
timestamp: Int!
|
||||||
blockNumber: Int!
|
blockNumber: Int!
|
||||||
@ -40,7 +40,7 @@ type Delegated @entity {
|
|||||||
delegateTo: Bytes!
|
delegateTo: Bytes!
|
||||||
}
|
}
|
||||||
|
|
||||||
type Undelegated @entity {
|
type Undelegate @entity {
|
||||||
id: ID!
|
id: ID!
|
||||||
timestamp: Int!
|
timestamp: Int!
|
||||||
blockNumber: Int!
|
blockNumber: Int!
|
||||||
@ -51,7 +51,7 @@ type Undelegated @entity {
|
|||||||
delegateFrom: Bytes!
|
delegateFrom: Bytes!
|
||||||
}
|
}
|
||||||
|
|
||||||
type StakeBurned @entity {
|
type StakeBurn @entity {
|
||||||
id: ID!
|
id: ID!
|
||||||
timestamp: Int!
|
timestamp: Int!
|
||||||
blockNumber: Int!
|
blockNumber: Int!
|
||||||
@ -62,7 +62,7 @@ type StakeBurned @entity {
|
|||||||
amountBurned: BigInt!
|
amountBurned: BigInt!
|
||||||
}
|
}
|
||||||
|
|
||||||
type StakeDailyBurned @entity {
|
type StakeDailyBurn @entity {
|
||||||
id: ID!
|
id: ID!
|
||||||
date: Int!
|
date: Int!
|
||||||
dailyAmountBurned: BigInt!
|
dailyAmountBurned: BigInt!
|
||||||
|
@ -1,21 +1,21 @@
|
|||||||
import { BigInt } from "@graphprotocol/graph-ts";
|
import { BigInt } from "@graphprotocol/graph-ts";
|
||||||
import {
|
import {
|
||||||
Proposal,
|
Proposal,
|
||||||
Voted,
|
Vote,
|
||||||
Delegated,
|
Delegate,
|
||||||
Undelegated,
|
Undelegate,
|
||||||
StakeBurned,
|
StakeBurn,
|
||||||
StakeDailyBurned,
|
StakeDailyBurn,
|
||||||
} from "../generated/schema";
|
} from "../generated/schema";
|
||||||
import {
|
import {
|
||||||
ProposalCreated,
|
ProposalCreated,
|
||||||
ProposalExecuted,
|
ProposalExecuted,
|
||||||
Voted as VotedEvent,
|
Voted,
|
||||||
Delegated as DelegatedEvent,
|
Delegated,
|
||||||
Undelegated as UndelegatedEvent,
|
Undelegated,
|
||||||
} from "../generated/Governance/Governance";
|
} from "../generated/Governance/Governance";
|
||||||
import {
|
import {
|
||||||
StakeBurned as StakeBurnedEvent
|
StakeBurned
|
||||||
} from "../generated/RelayerRegistry/RelayerRegistry";
|
} from "../generated/RelayerRegistry/RelayerRegistry";
|
||||||
|
|
||||||
export let ZERO_BI = BigInt.fromI32(0);
|
export let ZERO_BI = BigInt.fromI32(0);
|
||||||
@ -50,11 +50,11 @@ export function handleProposalExecuted(event: ProposalExecuted): void {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function handleVoted(event: VotedEvent): void {
|
export function handleVoted(event: Voted): void {
|
||||||
let voted = Voted.load(event.transaction.hash.toHex() + '_' + event.logIndex.toString());
|
let voted = Vote.load(event.transaction.hash.toHex() + '_' + event.logIndex.toString());
|
||||||
|
|
||||||
if (voted === null) {
|
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.timestamp = event.block.timestamp.toI32();
|
||||||
voted.blockNumber = event.block.number.toI32();
|
voted.blockNumber = event.block.number.toI32();
|
||||||
voted.logIndex = event.logIndex.toI32();
|
voted.logIndex = event.logIndex.toI32();
|
||||||
@ -70,11 +70,11 @@ export function handleVoted(event: VotedEvent): void {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function handleDelegated(event: DelegatedEvent): void {
|
export function handleDelegated(event: Delegated): void {
|
||||||
let delegated = Delegated.load(event.transaction.hash.toHex() + '_' + event.logIndex.toString());
|
let delegated = Delegate.load(event.transaction.hash.toHex() + '_' + event.logIndex.toString());
|
||||||
|
|
||||||
if (delegated === null) {
|
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.timestamp = event.block.timestamp.toI32();
|
||||||
delegated.blockNumber = event.block.number.toI32();
|
delegated.blockNumber = event.block.number.toI32();
|
||||||
delegated.logIndex = event.logIndex.toI32();
|
delegated.logIndex = event.logIndex.toI32();
|
||||||
@ -86,11 +86,11 @@ export function handleDelegated(event: DelegatedEvent): void {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function handleUndelegated(event: UndelegatedEvent): void {
|
export function handleUndelegated(event: Undelegated): void {
|
||||||
let undelegated = Undelegated.load(event.transaction.hash.toHex() + '_' + event.logIndex.toString());
|
let undelegated = Undelegate.load(event.transaction.hash.toHex() + '_' + event.logIndex.toString());
|
||||||
|
|
||||||
if (undelegated === null) {
|
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.timestamp = event.block.timestamp.toI32();
|
||||||
undelegated.blockNumber = event.block.number.toI32();
|
undelegated.blockNumber = event.block.number.toI32();
|
||||||
undelegated.logIndex = event.logIndex.toI32();
|
undelegated.logIndex = event.logIndex.toI32();
|
||||||
@ -102,11 +102,11 @@ export function handleUndelegated(event: UndelegatedEvent): void {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function handleStakeBurned(event: StakeBurnedEvent): void {
|
export function handleStakeBurned(event: StakeBurned): void {
|
||||||
let stakeBurned = StakeBurned.load(event.transaction.hash.toHex() + '_' + event.logIndex.toString());
|
let stakeBurned = StakeBurn.load(event.transaction.hash.toHex() + '_' + event.logIndex.toString());
|
||||||
|
|
||||||
if (stakeBurned === null) {
|
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.timestamp = event.block.timestamp.toI32();
|
||||||
stakeBurned.blockNumber = event.block.number.toI32();
|
stakeBurned.blockNumber = event.block.number.toI32();
|
||||||
stakeBurned.logIndex = event.logIndex.toI32();
|
stakeBurned.logIndex = event.logIndex.toI32();
|
||||||
@ -120,10 +120,10 @@ export function handleStakeBurned(event: StakeBurnedEvent): void {
|
|||||||
let dayID = timestamp / 86400;
|
let dayID = timestamp / 86400;
|
||||||
let dayStartTimestamp = dayID * 86400;
|
let dayStartTimestamp = dayID * 86400;
|
||||||
|
|
||||||
let dailyBurned = StakeDailyBurned.load(dayStartTimestamp.toString());
|
let dailyBurned = StakeDailyBurn.load(dayStartTimestamp.toString());
|
||||||
|
|
||||||
if (dailyBurned === null) {
|
if (dailyBurned === null) {
|
||||||
dailyBurned = new StakeDailyBurned(dayStartTimestamp.toString());
|
dailyBurned = new StakeDailyBurn(dayStartTimestamp.toString());
|
||||||
dailyBurned.date = dayStartTimestamp;
|
dailyBurned.date = dayStartTimestamp;
|
||||||
dailyBurned.dailyAmountBurned = ZERO_BI;
|
dailyBurned.dailyAmountBurned = ZERO_BI;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user