-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathschema.graphql
287 lines (267 loc) · 6.85 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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
# Entity to represent a collection
# defined on chain as pub type Collection<T: Config<I>, I: 'static = ()>
# https://github.com/paritytech/polkadot-sdk/blob/b8ad0d1f565659f004165c5244acba78828d0bf7/substrate/frame/nfts/src/lib.rs#L217
type CollectionEntity @entity {
attributes: [Attribute!]
baseUri: String
blockNumber: BigInt @index
burned: Boolean!
createdAt: DateTime! @index
currentOwner: String!
distribution: Int!
events: [CollectionEvent!] @derivedFrom(field: "collection")
floor: BigInt! @index
hash: String! @unique
highestSale: BigInt! @index
id: ID!
image: String
issuer: String!
kind: Kind
max: Int
media: String
meta: MetadataEntity
metadata: String
name: String @index
nftCount: Int! @index
nfts: [NFTEntity!] @derivedFrom(field: "collection")
ownerCount: Int!
recipient: String
royalty: Float
supply: Int! @index
updatedAt: DateTime! @index
version: Int!
volume: BigInt! @index
type: CollectionType
settings: CollectionSettings
}
# Entity to group NFTEntity by common metadata
# grouping is done either by NFTEntity.image or NFTEntity.media
# https://github.com/paritytech/polkadot-sdk/blob/b8ad0d1f565659f004165c5244acba78828d0bf7/substrate/frame/nfts/src/lib.rs#L293
type TokenEntity @entity {
id: ID!
blockNumber: BigInt
collection: CollectionEntity
count: Int!
createdAt: DateTime!
deleted: Boolean!
hash: String! @index
image: String
media: String
meta: MetadataEntity
metadata: String
name: String @index
nfts: [NFTEntity!] @derivedFrom(field: "token")
supply: Int!
updatedAt: DateTime!
}
# Entity to represent a collection
# defined on chain as pub type Item<T: Config<I>, I: 'static = ()>
# https://github.com/paritytech/polkadot-sdk/blob/b8ad0d1f565659f004165c5244acba78828d0bf7/substrate/frame/nfts/src/lib.rs#L271
type NFTEntity @entity {
attributes: [Attribute!]
blockNumber: BigInt @index
burned: Boolean!
collection: CollectionEntity!
createdAt: DateTime! @index
currentOwner: String! @index
events: [Event!] @derivedFrom(field: "nft")
hash: String! @index
id: ID!
image: String
issuer: String!
lewd: Boolean!
media: String
meta: MetadataEntity
metadata: String
name: String @index
price: BigInt @index
recipient: String
royalty: Float
sn: BigInt! @index
# swap: Swap @derivedFrom(field: "nft")
updatedAt: DateTime! @index
version: Int!
token: TokenEntity
}
# Entity to represent a Metadata
# defined on chain as pub type Metadata<T: Config<I>, I: 'static = ()>
# https://github.com/paritytech/polkadot-sdk/blob/b8ad0d1f565659f004165c5244acba78828d0bf7/substrate/frame/nfts/src/lib.rs#L283
type MetadataEntity @entity {
id: ID!
name: String
description: String
image: String
attributes: [Attribute!]
animationUrl: String
type: String
banner: String
kind: Kind
}
# Entity to represent an Attribute
# defined on chain as pub type Attribute<T: Config<I>, I: 'static = ()>
# https://github.com/paritytech/polkadot-sdk/blob/master/substrate/frame/nfts/src/lib.rs#L305
type Attribute @jsonField {
display: String
trait: String
value: String!
}
# Entity to represent a CollectionSettings
# defined on chain as pub type CollectionSettings<T: Config<I>, I: 'static = ()>
# https://github.com/paritytech/polkadot-sdk/blob/b8ad0d1f565659f004165c5244acba78828d0bf7/substrate/frame/nfts/src/lib.rs#L366
type CollectionSettings @jsonField {
value: String
startBlock: BigInt
endBlock: BigInt
price: BigInt
}
# Abstract entity to represent an event
# https://graphql.org/learn/schema/#interfaces
interface EventType {
id: ID!
blockNumber: BigInt
timestamp: DateTime!
caller: String!
currentOwner: String
interaction: Interaction!
# version: Int!
meta: String!
}
# Entity to represent an event defined by Interaction
type Event implements EventType @entity {
id: ID!
blockNumber: BigInt
timestamp: DateTime!
caller: String!
currentOwner: String! # currentOwner
interaction: Interaction!
meta: String!
nft: NFTEntity!
# version: Int!
}
type CollectionEvent implements EventType @entity {
id: ID!
blockNumber: BigInt
timestamp: DateTime!
caller: String!
currentOwner: String # currentOwner
interaction: Interaction!
meta: String!
collection: CollectionEntity!
# version: Int!
}
# type TradeEvent implements EventType @entity {
# id: ID!
# blockNumber: BigInt
# caller: String!
# currentOwner: String # currentOwner
# interaction: OfferInteraction!
# meta: String!
# trade: Swap!
# timestamp: DateTime!
# }
# Entity to represent a Offer
# defined on chain as pub type PendingSwapOf<T: Config<I>, I: 'static = ()>
# https://github.com/paritytech/polkadot-sdk/blob/d0d8e29197a783f3ea300569afc50244a280cafa/substrate/frame/nfts/src/types.rs#L207
type Offer @entity {
id: ID! # collection-id // same as NFTEntity.id
# events: [TradeEvent!] @derivedFrom(field: "offer")
blockNumber: BigInt!
caller: String!
considered: CollectionEntity!
createdAt: DateTime!
desired: NFTEntity
expiration: BigInt!
nft: NFTEntity! @unique
price: BigInt!
status: TradeStatus!
updatedAt: DateTime
}
# DEV: Consideration is not used
# type Consideration @entity {
# id: ID!
# collection: CollectionEntity!
# nft: NFTEntity
# }
# Entity to represent a Swap
# defined on chain as pub type PendingSwapOf<T: Config<I>, I: 'static = ()>
# https://github.com/paritytech/polkadot-sdk/blob/d0d8e29197a783f3ea300569afc50244a280cafa/substrate/frame/nfts/src/types.rs#L207
type Swap @entity {
id: ID! # collection-id // same as NFTEntity.id
# events: [TradeEvent!] @derivedFrom(field: "offer")
blockNumber: BigInt!
caller: String!
considered: CollectionEntity!
createdAt: DateTime!
desired: NFTEntity
expiration: BigInt!
nft: NFTEntity! @unique
price: BigInt
status: TradeStatus!
surcharge: Surcharge
updatedAt: DateTime
}
# Possible on-chain interactions that we listen for
enum Interaction {
BURN
BUY
CREATE
DESTROY
LIST
MINT
SEND
UNLIST
LOCK
CHANGEISSUER
PAY_ROYALTY
OFFER
SWAP
# ROYALTY
}
# Possible collection types
# HolderOf: user can mint if they hold a NFT from a specific collection
# Issuer: only the issuer can mint
# Public: anyone can mint
enum CollectionType {
HolderOf
Issuer
Public
}
enum Surcharge {
Receive
Send
}
enum TradeInteraction {
CREATE
ACCEPT
CANCEL
}
enum TradeStatus {
ACCEPTED
ACTIVE
CANCELLED
EXPIRED
INVALID
WITHDRAWN
}
enum Kind {
poap
pfp
genart
mixed
# audio
# video
}
# Entity to represent a Fungible Asset
# defined on chain as pub type Asset<T: Config<I>, I: 'static = ()>
# https://github.com/paritytech/polkadot-sdk/blob/99234440f0f8b24f7e4d1d3a0102a9b19a408dd3/substrate/frame/assets/src/lib.rs#L325
type AssetEntity @entity {
id: ID!
name: String
symbol: String
decimals: Int
}
# Entity to represent when the cache was last updated
type CacheStatus @entity {
id: ID!
lastBlockTimestamp: DateTime!
}