-
Notifications
You must be signed in to change notification settings - Fork 45
/
Copy pathschema.graphql
602 lines (468 loc) · 19.2 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
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
# Types
#############################
########## Tokens ###########
#############################
"""
Interface representing a generic token. Each entity implementing this interface can be queried as Token.
"""
interface Token {
" The address of the Token Smart Contract. "
id: ID!
" The name of the token, mirrored from the smart contract. "
name: String
" The symbol of the token, mirrored from the smart contract. "
symbol: String
}
"""
An [ERC20 Token Smart Contract](https://eips.ethereum.org/EIPS/eip-20), of type Token.
"""
type ERC20Contract implements Token @entity(immutable: true) {
" The address of the [ERC20 Token Smart Contract](https://eips.ethereum.org/EIPS/eip-20). "
id: ID!
" The name of the token, mirrored from the smart contract. "
name: String
" The symbol of the token, mirrored from the smart contract. "
symbol: String
" The number of decimals of the token, mirrored from the smart contract. "
decimals: Int!
}
"""
[ERC721 Token Standard](https://eips.ethereum.org/EIPS/eip-721), Non-Fungible Token (NFT), of type Token.
"""
type ERC721Contract implements Token @entity(immutable: true) {
" The address of the [ERC721 Token Smart Contract](https://eips.ethereum.org/EIPS/eip-721). "
id: ID!
" The name of the token, mirrored from the smart contract. "
name: String
" The symbol of the token, mirrored from the smart contract. "
symbol: String
}
"""
[ERC1155 Multi-Token Standard](https://eips.ethereum.org/EIPS/eip-1155), fungible, non-fungible, and semi-fungible tokens all in one contract,
type of Token.
"""
type ERC1155Contract implements Token @entity(immutable: true) {
" The address of the [ERC1155 Token Smart Contract](https://eips.ethereum.org/EIPS/eip-1155). "
id: ID!
" The name of the [ERC1155 Token Smart Contract](https://eips.ethereum.org/EIPS/eip-1155). "
name: String
" The symbol of the [ERC1155 Token Smart Contract](https://eips.ethereum.org/EIPS/eip-1155). "
symbol: String
}
###########################
##### Token Balances ######
###########################
"""
Balance of the DAO for any kind of token. Each entity implementing this interface can be queried as TokenBalance.
"""
interface TokenBalance {
" The concatenation of DAO Smart contract address and Token Smart Contract address. Joined by '_'. "
id: ID!
" The DAO that holds the Tokens"
dao: Dao!
" The block timestamp of the last update (transfer) for this token balance. "
lastUpdated: BigInt!
}
"""
The ERC20 Token balances for the DAO.
"""
type ERC20Balance implements TokenBalance @entity {
" The concatenation of DAO Smart contract address and Token Smart contract address. Joined by '_'. "
id: ID!
" The [ERC20 Token Smart Contract](https://eips.ethereum.org/EIPS/eip-20) instance. "
token: ERC20Contract!
" The DAO that holds the ERC20 token. "
dao: Dao!
" The amount of ERC20 tokens held by the DAO. "
balance: BigInt!
" The block timestamp of the last update (transfer) for this token balance. "
lastUpdated: BigInt!
}
"""
The Native token balances of the DAO, representing the amount of the blockchain's native currency
(e.g., Ether on Ethereum, MATIC on Polygon) held by the DAO.
"""
type NativeBalance implements TokenBalance @entity {
" The concatenation of DAO Smart contract address and Token Smart contract address. Joined by '_'. "
id: ID!
" The DAO that holds the native tokens"
dao: Dao!
" The amount of native tokens held by the DAO. "
balance: BigInt!
" The block timestamp of the last update (transfer) for this native token balance. "
lastUpdated: BigInt!
}
"""
The NFT balances of the DAO. Including all Token IDs held by the DAO per [ERC721 Token Smart Contract](https://eips.ethereum.org/EIPS/eip-721).
"""
type ERC721Balance implements TokenBalance @entity {
" The concatenation of DAO Smart Contract address and [ERC721 Token Smart Contract](https://eips.ethereum.org/EIPS/eip-721) address. Joined by '_'. "
id: ID!
" The [ERC721 Token Smart Contract](https://eips.ethereum.org/EIPS/eip-721) instance. "
token: ERC721Contract!
" The DAO that holds tokens from a [ERC721 Token Smart Contract](https://eips.ethereum.org/EIPS/eip-721). "
dao: Dao!
" The NFTs from one ERC721 Contract held by the DAO. "
tokenIds: [BigInt!]!
" The block timestamp of the last update (transfer) for this token balance. "
lastUpdated: BigInt!
}
"""
The ERC1155 Token balances of the DAO. Including all Token IDs and it's amounts held by the DAO per [ERC1155 Token Smart Contract](https://eips.ethereum.org/EIPS/eip-1155).
"""
type ERC1155Balance implements TokenBalance @entity {
" The concatenation of DAO Smart Contract address and [ERC1155 Token Smart Contract](https://eips.ethereum.org/EIPS/eip-1155) address. Joined by '_'. "
id: ID!
" The [ERC1155 Token Smart Contract](https://eips.ethereum.org/EIPS/eip-1155) instance. "
token: ERC1155Contract!
" The DAO that holds tokens from a [ERC1155 Token Smart Contract](https://eips.ethereum.org/EIPS/eip-1155). "
dao: Dao!
" Balance for each token ID from an [ERC1155 Token Smart Contract](https://eips.ethereum.org/EIPS/eip-1155). "
balances: [ERC1155TokenIdBalance!]! @derivedFrom(field: "balance")
" The URI of the [ERC1155 Token Smart Contract](https://eips.ethereum.org/EIPS/eip-1155). "
metadataUri: String!
" The block timestamp of the last update (transfer) for this token balance. "
lastUpdated: BigInt!
}
"""
The DAO token balance for each token within an [ERC1155 Token Smart Contract](https://eips.ethereum.org/EIPS/eip-1155)
"""
type ERC1155TokenIdBalance @entity {
" The concatenation of DAO Smart Contract address, [ERC1155 Token Smart Contract](https://eips.ethereum.org/EIPS/eip-1155) and token ID. Joined by '_'. "
id: ID!
" One to Many relationship linking with ERC1155Balance entity. "
balance: ERC1155Balance!
" The ID for each different token in an [ERC1155 Token Smart Contract](https://eips.ethereum.org/EIPS/eip-1155) held by the DAO. "
tokenId: BigInt!
" The number of tokens held by the DAO per [ERC1155 Token Smart Contract](https://eips.ethereum.org/EIPS/eip-1155) and token ID. "
amount: BigInt!
" The block timestamp of the last update (transfer) for this token balance. "
lastUpdated: BigInt!
}
###########################
##### Token Transfers #####
###########################
"""
Classifies the types of transfers from the DAO's point of view.
"""
enum TransferType {
"""
When a DAO facilitates a transfer and neither the source nor the destination addresses match the DAO's. The DAO must
have token approval to execute the transfer via proposal, acting as an intermediary in the process.
"""
ExternalTransfer
" A withdrawal form the DAO treasury. Executed by the DAO via proposal calling `transfer`. "
Withdraw
"""
A deposit to the DAO treasury. Using either the DAO `deposit` function or executed by the DAO via proposal calling `transferFrom` as an action to transfer to itself.
The DAO must have token approval.
"""
Deposit
}
"""
Interface representing a generic token transfer associated with the DAO. Each entity implementing this interface can be queried as TokenTransfer (refer to `Enum` `TransferType` for a better understanding of transfers associated with the DAO meaning).
"""
interface TokenTransfer {
" The concatenation of the transfer transaction hash, the log index and the action index. Joined by '_'. "
id: ID!
" The DAO that manages the transfer. "
dao: Dao!
" The Ethereum address from which the tokens are being transferred. "
from: Bytes!
" The Ethereum address receiving the transfer. "
to: Bytes!
" The type of transfer (External, Withdraw, Deposit) from the DAO's POV. "
type: TransferType!
" The associated Execution container on the DAO, if applicable. If deposited using the DAO `deposit` function then will be empty. "
actionBatch: ActionBatch
" The hash of the transfer to track the transaction. "
txHash: Bytes!
" The timestamp of the block including transfer. "
createdAt: BigInt!
}
"""
Transfers of ERC20 token associated with the DAO, including transfers sent to, received by, or intermediated by the DAO (refer to `Enum` `TransferType` for a better understanding of transfers associated with the DAO meaning).
"""
type ERC20Transfer implements TokenTransfer @entity(immutable: true) {
" The concatenation of the transfer transaction hash, the log index and the action index. Joined by '_'. "
id: ID!
" The DAO that manages the transfer. "
dao: Dao!
" The ERC20 Smart Contract Token entity involved in the transfer. "
token: Token!
" The amount of ERC20 token transferred. "
amount: BigInt!
" The Ethereum address from which the ERC20 tokens are being transferred. "
from: Bytes!
" The Ethereum address receiving the ERC20 tokens. "
to: Bytes!
" The associated DAO transaction, if applicable. If deposited Using the DAO `deposit` function then will be empty "
actionBatch: ActionBatch
" The type of transfer (External, Withdraw, Deposit) from the DAO's POV. "
type: TransferType!
" The hash of the ERC20 token transfer to track the transaction. "
txHash: Bytes!
" The timestamp of the block including the ERC20 token transfer. "
createdAt: BigInt!
}
"""
Transfers of ERC721 token associated with the DAO, including transfers sent to, received by, or intermediated by the DAO (refer to `Enum` `TransferType` for a better understanding of transfers associated with the DAO meaning).
"""
type ERC721Transfer implements TokenTransfer @entity(immutable: true) {
" The concatenation of the transfer transaction hash, the log index and the action index. Joined by '_'. "
id: ID!
" The DAO that manages the transfer. "
dao: Dao!
" The ERC721 Smart Contract Token entity involved in the transfer. "
token: ERC721Contract!
" The ID of the transferred token. "
tokenId: BigInt!
" The Ethereum address from which the ERC721 token is being transferred. "
from: Bytes!
" The Ethereum address receiving the ERC721 token. "
to: Bytes!
" The associated DAO transaction, if applicable. If deposited Using the DAO `deposit` function then will be empty "
actionBatch: ActionBatch
" The type of transfer (External, Withdraw, Deposit) from the DAO's POV. "
type: TransferType!
" The hash of the ERC721 token transfer to track the transaction. "
txHash: Bytes!
" The timestamp of the block including the ERC721 token transfer . "
createdAt: BigInt!
}
"""
Transfers of ERC1155 token associated with the DAO, including transfers sent to, received by, or intermediated by the DAO (refer to `Enum` `TransferType` for a better understanding of transfers associated with the DAO meaning).
"""
type ERC1155Transfer implements TokenTransfer @entity(immutable: true) {
" The concatenation of the transfer transaction hash, the log index and the action index. Joined by '_'. "
id: ID!
" The DAO that manages the transfer. "
dao: Dao!
" The ERC1155 Smart Contract Token entity involved in the transfer. "
token: ERC1155Contract!
" The ID of the transferred token. "
tokenId: BigInt!
" The amount of transferred tokens. "
amount: BigInt!
" The Ethereum address performing the token transfer. "
operator: Bytes!
" The Ethereum address from which the tokens are being transferred. "
from: Bytes!
" The Ethereum address receiving the tokens. "
to: Bytes!
" The associated DAO transaction, if applicable. If deposited Using the DAO `deposit` function then will be empty "
actionBatch: ActionBatch
" The type of transfer (External, Withdraw, Deposit) from the DAO's POV. "
type: TransferType!
" The hash of the ERC1155 token transfer to track the transaction. "
txHash: Bytes!
" The timestamp of the block including the ERC1155 token transfer. "
createdAt: BigInt!
}
"""
Transfers of Native token associated with the DAO, including transfers sent to, received by, or intermediated by the DAO (refer to `Enum` `TransferType` for a better understanding of transfers associated with the DAO meaning).
"""
type NativeTransfer implements TokenTransfer @entity(immutable: true) {
" The concatenation of the transfer transaction hash, the log index and the action index (set to 0). Joined by '_'. "
id: ID!
" The DAO that manages the transfer. "
dao: Dao!
" The amount of transferred native tokens . "
amount: BigInt!
" The Ethereum address from which the native tokens are being transferred. "
from: Bytes!
" The Ethereum address receiving the native tokens. "
to: Bytes!
" The reference describing the deposit reason. "
reference: String!
" The associated DAO transaction, if applicable. If deposited Using the DAO `deposit` function then will be empty "
actionBatch: ActionBatch
" The type of transfer (External, Withdraw, Deposit) from the DAO's POV. "
type: TransferType!
" The hash of the native token transfer to track the transaction. "
txHash: Bytes!
" The timestamp of the native token transfer block. "
createdAt: BigInt!
}
#############################
######## Executions #########
#############################
"""
A container for actions executed in batches by the DAO's `execute` function.
"""
type ActionBatch @entity(immutable: true) {
" generateActionBatchEntityId: Concatenation caller, daoAddress, callId, transactionHash and txLogIndex. Joined by '_'. "
id: ID!
" generateDeterministicActionBatchId: Concatenation caller, daoAddress, callId. Joined by '_'. "
deterministicId: String!
dao: Dao!
creator: Bytes!
metadata: String
actions: [Action!]! @derivedFrom(field: "actionBatch")
allowFailureMap: BigInt!
failureMap: BigInt
executed: Boolean!
createdAt: BigInt!
executionTxHash: Bytes
}
type Action @entity(immutable: true) {
" generateActionEntityId: Concatenation caller, daoAddress, callId, actionIdx, transactionHash and txLogIndex. Joined by '_'. "
id: ID!
" generateDeterministicActionId: Concatenation caller, daoAddress, callId, actionIdx. Joined by '_'. "
deterministicId: String!
" container for the actions executed in batches by the DAO's `execute` function. "
actionBatch: ActionBatch!
" The DAO that executed the action. "
dao: Dao!
" The address to call. "
to: Bytes!
" The native token value to be sent with the call. "
value: BigInt!
" The bytes-encoded function selector and calldata for the call. "
data: Bytes!
" The result obtained from the executed action in `bytes`. "
execResult: Bytes
}
"""
The supported callback functions for ERC standards registered with [ERC-165](https://eips.ethereum.org/EIPS/eip-165) interface ID and callback function signature.
"""
type StandardCallback @entity {
" Concatenation of the DAO address and the interfaceID. Joined by '_'. "
id: ID!
" The DAO associated with the supported callback functions. "
dao: Dao!
" The interface identifier, as specified in [ERC-165](https://eips.ethereum.org/EIPS/eip-165) (XOR of all function selectors in the interface). "
interfaceId: Bytes!
" The selector of the registered callback function. "
callbackSelector: Bytes!
" The magic number registered for the function signature. "
magicNumber: Bytes!
}
# DAO
type Dao @entity {
id: ID! # use address as id
subdomain: String
creator: Bytes!
daoURI: String
metadata: String
createdAt: BigInt!
txHash: Bytes!
token: ERC20Contract
actions: [Action!]! @derivedFrom(field: "dao")
transfers: [TokenTransfer!]! @derivedFrom(field: "dao")
balances: [TokenBalance!]! @derivedFrom(field: "dao")
permissions: [Permission!]! @derivedFrom(field: "dao")
actionBatch: [ActionBatch!]! @derivedFrom(field: "dao")
trustedForwarder: Bytes
signatureValidator: Bytes
standardCallbacks: [StandardCallback!]! @derivedFrom(field: "dao")
plugins: [PluginInstallation!]! @derivedFrom(field: "dao")
}
# ACL
# Cannot be immutable because a permission can be revoked and granted in the same TX.
# This results in an error in the subgraph if the entity is immutable.
# No need to store granted as we can delete permission when revoked
type Permission @entity {
id: ID! # emitting contract Address (DAO or PluginRepo) + permissionId + where + who
where: Bytes!
permissionId: Bytes!
who: Bytes!
actor: Bytes!
condition: Bytes
# The following attributes is used to create
# one-to-many between DAO or PluginRepo to Permission
dao: Dao
pluginRepo: PluginRepo
}
# Plugins
type PluginRepo @entity(immutable: true) {
id: ID! # address
subdomain: String!
releases: [PluginRelease!]! @derivedFrom(field: "pluginRepo")
# Holds all preparations. Also applied ones.
preparations: [PluginPreparation!]! @derivedFrom(field: "pluginRepo")
# Holds all installed and uninstalled installations.
installations: [PluginInstallation!] @derivedFrom(field: "appliedPluginRepo")
permissions: [Permission!]! @derivedFrom(field: "pluginRepo")
}
type PluginSetup @entity(immutable: true) {
id: ID! # contract address
versions: [PluginVersion!]! @derivedFrom(field: "pluginSetup")
}
type PluginRelease @entity {
id: ID! # pluginRepo + release
pluginRepo: PluginRepo!
release: Int!
metadata: String! # release metadata
builds: [PluginVersion!]! @derivedFrom(field: "release")
}
type PluginVersion @entity(immutable: true) {
id: ID! # pluginRepo + release + build
pluginRepo: PluginRepo!
pluginSetup: PluginSetup
release: PluginRelease!
build: Int!
metadata: String! # build metadata
# Holds all preparations. Also applied ones.
preparations: [PluginPreparation!]! @derivedFrom(field: "pluginVersion")
# Holds all installed and uninstalled installations.
installations: [PluginInstallation!] @derivedFrom(field: "appliedVersion")
}
type PluginPermission @entity(immutable: true) {
id: ID! # PluginPreparation + operation + where + who + permissionId
pluginPreparation: PluginPreparation!
operation: PermissionOperation!
where: Bytes!
who: Bytes!
condition: Bytes
permissionId: Bytes!
}
enum PermissionOperation {
Grant
Revoke
GrantWithCondition
}
type PluginPreparation @entity(immutable: true) {
id: ID! # psp setupId + installationId
installation: PluginInstallation!
creator: Bytes!
dao: Dao!
preparedSetupId: Bytes! # the psp setupId
pluginRepo: PluginRepo!
pluginVersion: PluginVersion!
data: Bytes
pluginAddress: Bytes!
helpers: [Bytes!]!
permissions: [PluginPermission!]! @derivedFrom(field: "pluginPreparation")
type: PluginPreparationType!
}
# Don't implement IPlugin. Otherwise it would show up under plugins in the DAO entity
type PluginInstallation @entity {
id: ID! # psp installationId
dao: Dao!
plugin: IPlugin # The plugin address as id provided by the applied preparation
appliedPreparation: PluginPreparation
appliedSetupId: Bytes # The setupId of the application see PSP documentation for more info
appliedVersion: PluginVersion # Stored to track installations in the different plugin versions
appliedPluginRepo: PluginRepo # Stored to track installation in the different plugin repos
preparations: [PluginPreparation!]! @derivedFrom(field: "installation")
state: PluginPreparationState!
}
enum PluginPreparationType {
Installation
Update
Uninstallation
}
enum PluginPreparationState {
InstallationPrepared
Installed
UpdatePrepared
UninstallPrepared
Uninstalled
}
interface IPlugin {
id: ID! # plugin address
dao: Dao!
pluginAddress: Bytes!
installations: [PluginInstallation!]! @derivedFrom(field: "plugin")
}