-
Notifications
You must be signed in to change notification settings - Fork 0
/
schema.graphql
143 lines (109 loc) · 3.31 KB
/
schema.graphql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# Tracks general Moonbase Bridge data
type General @entity {
id: ID! # '1'
totalDepositsCount: BigInt
totalProposalsCount: BigInt
totalVotesCount: BigInt
totalRelayersCount: BigInt
chainId: Int!
subgraphVersion: String!
}
# Dynamically tracks data for each relayer
type Relayer @entity {
id: ID! # relayer address
addedTimestamp: BigInt!
addedBlockNumber: BigInt!
removedTimestamp: BigInt # we keep the relayer entity in store merely adding the time and block when the relayer got removed so the entity can still be queried
removedBlockNumber: BigInt
votes: [Vote!] @derivedFrom(field: "relayer")
voteCount: BigInt!
threshold: BigInt
createdProposals: [Proposal!] @derivedFrom(field: "createdBy")
passedProposals: [Proposal!] @derivedFrom(field: "passedBy")
executedProposals: [Proposal!] @derivedFrom(field: "executedBy")
canceledProposals: [Proposal!] @derivedFrom(field: "canceledBy")
# last updated
timestamp: BigInt!
blockNumber: BigInt!
}
# Tracks each Deposit, however we don't name this entity `Deposit` as entity names should not be identical
# to event names as good coding practice and to avoid confusion.
type UserDeposit @entity {
id: ID! # originChainID => destinationChainID - nonce
originChainId: Int!
destinationChainId: Int!
resourceId: Bytes!
nonce: BigInt!
proposal: Proposal
createdTimestamp: BigInt!
createdBlockNumber: BigInt!
}
# Dynamically tracks Proposals
type Proposal @entity {
id: ID! # originChainID => destinationChainID - nonce
deposit: UserDeposit! @derivedFrom(field: "proposal")
originChainId: Int!
destinationChainId: Int!
resourceId: Bytes!
status: String!
dataHash: Bytes!
createdBy: Relayer
passedBy: Relayer
executedBy: Relayer
canceledBy: Relayer
votes: [Vote!] @derivedFrom(field: "proposal")
createdTimestamp: BigInt!
createdBlockNumber: BigInt!
passedTimestamp: BigInt
passedBlockNumber: BigInt
executedTimestamp: BigInt
executedBlockNumber: BigInt
canceledTimestamp: BigInt
canceledBlockNumber: BigInt
}
# Dynamically tracks how many Proposals occured for each direction of the bridge
type ProposalCount @entity {
id: ID! # originChainId => destinationChainId
originChainId: Int!
destinationChainId: Int!
count: BigInt!
# last updated
timestamp: BigInt!
blockNumber: BigInt!
}
# Tracks each vote
type Vote @entity {
id: ID! # proposal ID - address of the voting relayer
relayer: Relayer!
proposal: Proposal!
approved: Boolean! # the occurance of a `ProposalVote` event indicates that the vote is `true`
votedTimestamp: BigInt!
votedBlockNumber: BigInt!
}
# Tracks each user and their roles
type User @entity {
id: ID! # wallet address
roles: [Role!] @derivedFrom(field: "user") # this field can be queried for both active and revoked roles
createdTimestamp: BigInt!
createdBlockNumber: BigInt!
}
# Tracks role related data
type Role @entity {
id: ID! # role hash - wallet address
user: User!
role: String!
sender: Bytes!
currentlyHeld: Boolean! # need to check this field to ensure query returns only active roles
# last updated
timestamp: BigInt!
blockNumber: BigInt!
}
# Tracks daily data for the Bridge
type DailyStatistic @entity {
id: ID!
date: Int!
depositsCount: BigInt
proposalsCount: BigInt
votesCount: BigInt
relayersCount: BigInt
}