-
Notifications
You must be signed in to change notification settings - Fork 0
/
schema.graphql
69 lines (63 loc) · 2.16 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
type Account @entity {
id: ID! # Set to `Account.address.toHexString()`
asErc20: Erc20Contract
Erc20balances: [Erc20Balance!]! @derivedFrom(field: "account")
Erc20approvalsOwner: [Erc20Approval!]! @derivedFrom(field: "owner")
Erc20approvalsSpender: [Erc20Approval!]! @derivedFrom(field: "spender")
Erc20transferFromEvent: [Erc20Transfer!]! @derivedFrom(field: "from")
Erc20transferToEvent: [Erc20Transfer!]! @derivedFrom(field: "to")
events: [Event!]! @derivedFrom(field: "emitter")
}
type Erc20Contract @entity(immutable: true) {
id: ID! # Set to `Erc20Contract.address.toHexString()`
asAccount: Account!
name: String
symbol: String
decimals: Int!
totalSupply: Erc20Balance!
balances: [Erc20Balance!]! @derivedFrom(field: "contract")
approvals: [Erc20Approval!]! @derivedFrom(field: "contract")
transfers: [Erc20Transfer!]! @derivedFrom(field: "contract")
}
type Erc20Balance @entity {
id: ID! # Set to `contract.id + '-' + (account ? account.id : 'totalSupply')`
contract: Erc20Contract!
account: Account
value: BigDecimal!
valueExact: BigInt!
transferFromEvent: [Erc20Transfer!]! @derivedFrom(field: "fromBalance")
transferToEvent: [Erc20Transfer!]! @derivedFrom(field: "toBalance")
}
type Erc20Approval @entity {
id: ID! # Set to `contract.id + '-' + owner.id + '-' + spender.id`
contract: Erc20Contract!
owner: Account!
spender: Account!
value: BigDecimal!
valueExact: BigInt!
}
type Erc20Transfer implements Event @entity(immutable: true) {
id: ID! # Set to `transaction.id + '-' + event.logIndex.toString()`
emitter: Account!
transaction: Transaction!
timestamp: BigInt!
contract: Erc20Contract!
from: Account
fromBalance: Erc20Balance
to: Account
toBalance: Erc20Balance
value: BigDecimal!
valueExact: BigInt!
}
interface Event {
id: ID!
transaction: Transaction!
emitter: Account!
timestamp: BigInt!
}
type Transaction @entity(immutable: true) {
id: ID! # Set to `event.transaction.hash.toHexString()`
timestamp: BigInt!
blockNumber: BigInt!
events: [Event!]! @derivedFrom(field: "transaction")
}