forked from TalentLayer/talentlayer-subgraph
-
Notifications
You must be signed in to change notification settings - Fork 0
/
schema.graphql
304 lines (277 loc) · 10.3 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
enum ServiceStatus {
Opened
Confirmed
Finished
Cancelled
Uncompleted
}
enum PaymentType {
Release
Reimburse
}
type Service @entity {
id: ID! # service id
createdAt: BigInt! # timestamp of block creation
updatedAt: BigInt! # timestamp of the last change
status: ServiceStatus! # service status
buyer: User # service buyer
seller: User # service seller
transaction: Transaction @derivedFrom(field: "service") # transaction associated with this service
proposals: [Proposal!] @derivedFrom(field: "service") # proposals for this service
platform: Platform # Platform on which service was created
cid: String
description: ServiceDescription
}
type ServiceDescription @entity(immutable: true) {
id: ID! #cid
service: Service!
title: String
about: String
startDate: BigInt
expectedEndDate: BigInt
latitude: String
longitude: String
rateToken: String
rateAmount: String
video_url: String
}
type Keyword @entity(immutable: true) {
id: ID! #Keyword
# Derived from does not currently work because of open issue with duplicated entities.
# Reason: createOrGetKeyword creates duplicated keywords from file data source (ipfs-data.ts)
# https://github.com/graphprotocol/graph-node/issues/4087
# serviceDescription: ServiceDescription @derivedFrom(field: "keywords")
}
type Review @entity(immutable: true) {
id: ID! # review nft id
service: Service! # service this review is for
createdAt: BigInt!
to: User! # reviewed user
rating: BigInt
cid: String
description: ReviewDescription
}
type ReviewDescription @entity(immutable: true) {
id: ID!
content: String
review: Review
}
type Token @entity {
id: ID! # token id
address: Bytes! # token entity
symbol: String! # token code
name: String! # token name
decimals: BigInt! # token decimals
allowed: Boolean! # Whether the token is whitelisted or not
minimumTransactionAmount: BigInt! # Minimum amount of token that can be transferred
}
type User @entity {
id: ID! # user nft id
index: BigInt! # index of user
handle: String! # handle of user
createdAt: BigInt!
updatedAt: BigInt!
platform: Platform # Platform on which user nft was minted
numReviews: BigInt # DEPRECATED - will be remove soon, use UserStats.numReceivedReviews instead
address: String! # wallet address of user
rating: BigDecimal! # average rating from reviews user has received
reviews: [Review!] @derivedFrom(field: "to") # reviews of user
buyerServices: [Service!] @derivedFrom(field: "buyer") # services user is an buyer for
sellerServices: [Service!] @derivedFrom(field: "seller") # services user is an seller for
totalGains: [UserGain!] @derivedFrom(field: "user")
cid: String #cid of the description
description: UserDescription # User description (off chain data)
delegates: [String!]! # list of user delegators
userStats: UserStats # User proposal, service & reviews statistics
}
type UserStats @entity {
id: ID! # ID of the user
numReceivedReviews: BigInt! # number of reviews user has received
numGivenReviews: BigInt! # number of reviews user has given
numCreatedServices: BigInt! # number of services user has created
numFinishedServicesAsBuyer: BigInt! # number of services user has finished as a buyer
numCreatedProposals: BigInt! # number of proposals user has created
numFinishedServicesAsSeller: BigInt! # number of services user has finished as a seller
user: User! # Corresponding user
}
type UserDescription @entity(immutable: true) {
id: ID! #cid
title: String
about: String
skills_raw: String
skills: [Keyword!]
timezone: BigInt
headline: String
country: String
user: User!
role: String # buyer, seller, both
name: String # Custom user name
video_url: String #url
image_url: String #url
}
enum ProposalStatus {
Pending
Validated
Rejected
}
type Proposal @entity {
id: ID! # concatenation of serviceId + seller TalentLayerId
service: Service! # service entity
createdAt: BigInt! # timestamp of block creation
updatedAt: BigInt! # timestamp of the last change
status: ProposalStatus! # Proposal status
seller: User # Proposal seller
rateToken: Token! # Rate token entity
rateAmount: BigInt # Rate amount
cid: String # cid of the description
platform: Platform # Platform on which proposal was created
description: ProposalDescription #Proposals that the description describes.
expirationDate: BigInt
}
type ProposalDescription @entity(immutable: true) {
id: ID! #Cid
proposal: Proposal!
startDate: BigInt
about: String
expectedHours: BigInt
video_url: String
}
#NB: Payment sender will always be the Escrow Contract
type Payment @entity(immutable: true) {
id: ID! # autogenerated id
createdAt: BigInt # timestamp of block creation
service: Service! # service entity
amount: BigInt! # payment amount
rateToken: Token! # Rate token entity
paymentType: String # Whether the payment is a release or a reimbursement
transactionHash: String # Transaction hash of the transfer
transaction: Transaction! # transaction entity
}
enum TransactionStatus {
NoDispute
WaitingSender
WaitingReceiver
DisputeCreated
Resolved
}
type Transaction @entity {
id: ID! # transaction id
sender: User # sender of the transaction
receiver: User # receiver of the transaction
token: Token! # token entity
amount: BigInt! # amount
service: Service # service entity
protocolEscrowFeeRate: Int! # fee paid to the protocol
originServiceFeeRate: Int! # Fee asked by the platform which created the service
originValidatedProposalFeeRate: Int! # Fee asked by the platform on which the proposal was validated
disputeId: BigInt # id of the dispute if exists
senderFee: BigInt! # fees paid by the sender for arbitration
receiverFee: BigInt! # fees paid by the receiver for arbitration
lastInteraction: BigInt! # timestamp of the last interaction by parties with the dispute
senderFeePaidAt: BigInt # timestamp when the arbitration fee was paid by the sender
receiverFeePaidAt: BigInt # timestamp when the arbitration fee was paid by the receiver
status: TransactionStatus! # status of the payment
arbitrator: Bytes! # address of the arbitrator contract
arbitratorExtraData: Bytes! # extra data for the arbitrator
arbitrationFeeTimeout: BigInt! # timeout for the arbitration fee to be paid
ruling: BigInt # ruling of the arbitrator on the dispute
evidences: [Evidence!] @derivedFrom(field: "transaction") # proposals for this service
metaEvidenceUri: String! # uri of the dispute metadata
payments: [Payment!] @derivedFrom(field: "transaction") # payments related to this transaction
}
type Evidence @entity(immutable: true) {
id: ID! # autogenerated id
transaction: Transaction! # transaction entity
createdAt: BigInt! # Timestamp of block creation
party: User! # party that submitted the evidence
description: EvidenceDescription # ipfs data of the evidence
cid: String! # metadata URI of evidence
}
type EvidenceDescription @entity(immutable: true) {
id: ID! # Evidence cid + block.timestamp
evidence: Evidence! # Evidence entity
fileUri: String # "ipfs/" + cid of evidence
fileHash: String # hash of the evidence file
fileTypeExtension: String # extension of the evidence file
name: String # name of the evidence
description: String # description of the evidence
}
type Platform @entity {
id: ID! # platform id
address: Bytes! # wallet address of platform owner
name: String! # name of the platform
createdAt: BigInt!
updatedAt: BigInt!
feePayments: [FeePayment!] @derivedFrom(field: "platform") # Platform-related fee payments
totalPlatformGains: [PlatformGain!] @derivedFrom(field: "platform") # Platform-related total gains per token
feeClaims: [FeeClaim!] @derivedFrom(field: "platform") # Platform-related fee claims
originServiceFeeRate: Int! # Fee asked by the platform which created the service
originValidatedProposalFeeRate: Int! # Fee asked by the platform on which the proposal was validated
servicePostingFee: BigInt! # Flat fee asked by the platform to post a service
proposalPostingFee: BigInt! # Flat fee asked by the platform to post a proposal
arbitrator: Bytes! # address of the arbitrator contract
arbitratorExtraData: Bytes! # extra data for the arbitrator
arbitrationFeeTimeout: BigInt! # timeout for the arbitration fee to be paid
cid: String #cid of description
description: PlatformDescription
signer: Bytes! # address of the platform signer
}
type PlatformDescription @entity(immutable: true) {
id: ID! #cid
about: String #text
website: String #url
platform: Platform!
video_url: String
image_url: String
}
enum FeeType {
Platform
OriginPlatform
}
type FeePayment @entity(immutable: true) {
id: ID! # autogenerated id
createdAt: BigInt # timestamp of block creation
platform: Platform # platform entity
service: Service # service entity
type: FeeType! # fee type
token: Token # token entity
amount: BigInt # platform fee
}
type FeeClaim @entity(immutable: true) {
id: ID! # autogenerated id
createdAt: BigInt # timestamp of block creation
platform: Platform # platform entity
token: Token # token entity
amount: BigInt! # claim amount
transactionHash: String # Transaction hash of the transfer
}
type PlatformGain @entity {
id: ID! # concatenation of platformId + token entity
platform: Platform # platform entity
token: Token # token entity
totalOriginPlatformFeeGain: BigInt! # total Origin Platform gain
totalPlatformFeeGain: BigInt! # total Platform gain
}
type UserGain @entity {
id: ID! # concatenation of userId + token entity
user: User
token: Token # token entity
totalGain: BigInt! # total User gain
}
type Protocol @entity {
id: ID! # autogenerated id
userMintFee: BigInt! # protocol fee for minting a TL id
platformMintFee: BigInt! # protocol fee for minting a platform id
protocolEscrowFeeRate: Int! # protocol fee for each escrow transaction (percentage, per 10,000)
totalMintFees: BigInt! # total mint fees collected
minArbitrationFeeTimeout: BigInt! # minimum timeout to pay the arbitration fee
shortHandlesMaxPrice: BigInt! # maximum price for a short handle
minServiceCompletionPercentage: BigInt! # minimum percentage of released amount for considering a service completed
}
type _Schema_
@fulltext(
name: "serviceDescriptionSearchRank"
language: en
algorithm: proximityRank
include: [{ entity: "ServiceDescription", fields: [{ name: "title" }, { name: "keywords_raw" }] }]
)