-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathschema.prisma
322 lines (267 loc) · 10.4 KB
/
schema.prisma
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
// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema
generator client {
provider = "prisma-client-js"
previewFeatures = ["tracing", "metrics"]
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
enum BlobStorage {
FILE_SYSTEM @map("file_system")
GOOGLE @map("google")
POSTGRES @map("postgres")
SWARM @map("swarm")
@@map("blob_storage")
}
enum Rollup {
ARBITRUM @map("arbitrum")
BASE @map("base")
BLAST @map("blast")
BOBA @map("boba")
CAMP @map("camp")
KROMA @map("kroma")
LINEA @map("linea")
METAL @map("metal")
OPTIMISM @map("optimism")
OPTOPIA @map("optopia")
PARADEX @map("paradex")
PGN @map("pgn")
SCROLL @map("scroll")
STARKNET @map("starknet")
TAIKO @map("taiko")
ZKSYNC @map("zksync")
MODE @map("mode")
ZORA @map("zora")
@@map("rollup")
}
model BlockchainSyncState {
id Int @id @default(autoincrement())
lastAggregatedBlock Int? @map("last_aggregated_block")
lastFinalizedBlock Int? @map("last_finalized_block")
lastLowerSyncedSlot Int? @map("last_lower_synced_slot")
lastUpperSyncedSlot Int? @map("last_upper_synced_slot")
@@map("blockchain_sync_state")
}
//TODO: Rename to SwarmBatchStorage
model BlobStoragesState {
id Int @id @default(autoincrement())
swarmDataId String? @map("swarm_data_id") // TODO: rename to batchId
swarmDataTTL Int? @map("swarm_data_ttl") // TODO: rename to batchTtl
updatedAt DateTime @default(now()) @map("updated_at")
@@map("blob_storages_state")
}
model Address {
address String @id
firstBlockNumberAsSender Int? @map("first_block_number_as_sender")
firstBlockNumberAsReceiver Int? @map("first_block_number_as_receiver")
insertedAt DateTime @default(now()) @map("inserted_at")
updatedAt DateTime @default(now()) @map("updated_at")
transactionsAsSender Transaction[] @relation("senderAddressRelation")
transactionsAsReceiver Transaction[] @relation("receiverAddressRelation")
@@index([insertedAt])
@@map("address")
}
model Blob {
versionedHash String @id @map("versioned_hash")
commitment String @unique
proof String?
size Int
firstBlockNumber Int? @map("first_block_number")
insertedAt DateTime @default(now()) @map("inserted_at")
updatedAt DateTime @default(now()) @map("updated_at")
dataStorageReferences BlobDataStorageReference[]
transactions BlobsOnTransactions[]
@@index([insertedAt])
@@map("blob")
}
model BlobData {
id String @id
data Bytes
@@map("blob_data")
}
model BlobDataStorageReference {
blobHash String @map("blob_hash")
blobStorage BlobStorage @map("storage")
dataReference String @map("data_reference")
blob Blob @relation(fields: [blobHash], references: [versionedHash])
@@id([blobHash, blobStorage])
@@map("blob_data_storage_reference")
}
model Block {
hash String @id
number Int
timestamp DateTime @unique
slot Int @unique
blobGasUsed Decimal @map("blob_gas_used") @db.Decimal(100, 0)
excessBlobGas Decimal @map("excess_blob_gas") @db.Decimal(100, 0)
blobGasPrice Decimal @map("blob_gas_price") @db.Decimal(100, 0)
blobAsCalldataGasUsed Decimal @map("blob_as_calldata_gas_used") @db.Decimal(100, 0)
insertedAt DateTime @default(now()) @map("inserted_at")
updatedAt DateTime @default(now()) @map("updated_at")
blobsOnTransactions BlobsOnTransactions[]
transactions Transaction[]
transactionForks TransactionFork[]
@@index([number])
@@index([insertedAt])
@@map("block")
}
model Transaction {
hash String @id
fromId String @map("from_id")
toId String @map("to_id")
blockHash String @map("block_hash")
blockNumber Int @map("block_number")
blockTimestamp DateTime @map("block_timestamp")
index Int?
maxFeePerBlobGas Decimal @map("max_fee_per_blob_gas") @db.Decimal(100, 0)
gasPrice Decimal @map("gas_price") @db.Decimal(100, 0)
blobAsCalldataGasUsed Decimal @map("blob_as_calldata_gas_used") @db.Decimal(100, 0)
rollup Rollup?
insertedAt DateTime @default(now()) @map("inserted_at")
updatedAt DateTime @default(now()) @map("updated_at")
blobs BlobsOnTransactions[]
block Block @relation(fields: [blockHash], references: [hash])
from Address @relation("senderAddressRelation", fields: [fromId], references: [address])
to Address @relation("receiverAddressRelation", fields: [toId], references: [address])
transactionForks TransactionFork[]
@@index([insertedAt])
@@index([blockHash])
@@index([blockNumber])
@@index([blockNumber, index])
@@index([blockTimestamp])
@@map("transaction")
}
model BlobsOnTransactions {
blobHash String @map("blob_hash")
blockHash String @map("block_hash")
blockNumber Int @map("block_number")
blockTimestamp DateTime @map("block_timestamp")
txHash String @map("tx_hash")
index Int
blob Blob @relation(fields: [blobHash], references: [versionedHash])
block Block @relation(fields: [blockHash], references: [hash])
transaction Transaction @relation(fields: [txHash], references: [hash])
@@id([txHash, index])
@@index([blobHash])
@@index([blockHash])
@@index([blockNumber])
@@index([blockTimestamp])
@@index([txHash])
@@map("blobs_on_transactions")
}
model TransactionFork {
hash String
blockHash String @map("block_hash")
insertedAt DateTime @default(now()) @map("inserted_at")
updatedAt DateTime @default(now()) @map("updated_at")
block Block @relation(fields: [blockHash], references: [hash])
transaction Transaction @relation(fields: [hash], references: [hash])
@@id([hash, blockHash])
@@map("transaction_fork")
}
// Block Metrics
model BlockOverallStats {
id Int @id @default(autoincrement())
totalBlocks Int @map("total_blocks")
totalBlobGasUsed Decimal @map("total_blob_gas_used") @db.Decimal(100, 0)
totalBlobAsCalldataGasUsed Decimal @map("total_blob_as_calldata_gas_used") @db.Decimal(100, 0)
totalBlobFee Decimal @map("total_blob_fee") @db.Decimal(100, 0)
totalBlobAsCalldataFee Decimal @map("total_blob_as_calldata_fee") @db.Decimal(100, 0)
avgBlobFee Float @map("avg_blob_fee")
avgBlobAsCalldataFee Float @map("avg_blob_as_calldata_fee")
avgBlobGasPrice Float @map("avg_blob_gas_price")
updatedAt DateTime @map("updated_at")
@@map("block_overall_stats")
}
model BlockDailyStats {
day DateTime @id @db.Date
totalBlocks Int @map("total_blocks")
totalBlobGasUsed Decimal @map("total_blob_gas_used") @db.Decimal(100, 0)
totalBlobAsCalldataGasUsed Decimal @map("total_blob_as_calldata_gas_used") @db.Decimal(100, 0)
totalBlobFee Decimal @map("total_blob_fee") @db.Decimal(100, 0)
totalBlobAsCalldataFee Decimal @map("total_blob_as_calldata_fee") @db.Decimal(100, 0)
avgBlobFee Float @map("avg_blob_fee")
avgBlobAsCalldataFee Float @map("avg_blob_as_calldata_fee")
avgBlobGasPrice Float @map("avg_blob_gas_price")
@@unique([day])
@@index([day])
@@map("block_daily_stats")
}
// Transaction metrics
model TransactionOverallStats {
id Int @id @default(autoincrement())
totalTransactions Int @map("total_transactions")
totalUniqueReceivers Int @map("total_unique_receivers")
totalUniqueSenders Int @map("total_unique_senders")
avgMaxBlobGasFee Float @map("avg_max_blob_gas_fee")
updatedAt DateTime @map("updated_at")
@@map("transaction_overall_stats")
}
model TransactionDailyStats {
day DateTime @id @db.Date
totalTransactions Int @map("total_transactions")
totalUniqueSenders Int @map("total_unique_senders")
totalUniqueReceivers Int @map("total_unique_receivers")
avgMaxBlobGasFee Float @map("avg_max_blob_gas_fee")
@@map("transaction_daily_stats")
}
// Blob metrics
model BlobOverallStats {
id Int @id @default(autoincrement())
totalBlobs Int @map("total_blobs")
totalUniqueBlobs Int @map("total_unique_blobs")
totalBlobSize BigInt @map("total_blob_size")
updatedAt DateTime @map("updated_at")
@@map("blob_overall_stats")
}
model BlobDailyStats {
day DateTime @id @db.Date
totalBlobs Int @map("total_blobs")
totalUniqueBlobs Int @map("total_unique_blobs")
totalBlobSize BigInt @map("total_blob_size")
@@map("blob_daily_stats")
}
// NextAuth.js Models
// NOTE: When using postgresql, mysql or sqlserver,
// uncomment the @db.Text annotations below
// @see https://next-auth.js.org/schemas/models
// model Account {
// id String @id @default(cuid())
// userId String
// type String
// provider String
// providerAccountId String
// refresh_token String? @db.Text
// access_token String? @db.Text
// expires_at Int?
// token_type String?
// scope String?
// id_token String? @db.Text
// session_state String?
// user User @relation(fields: [userId], references: [id], onDelete: Cascade)
// @@unique([provider, providerAccountId])
// }
// model Session {
// id String @id @default(cuid())
// sessionToken String @unique
// userId String
// expires DateTime
// user User @relation(fields: [userId], references: [id], onDelete: Cascade)
// }
// model User {
// id String @id @default(cuid())
// name String?
// email String? @unique
// emailVerified DateTime?
// image String?
// accounts Account[]
// sessions Session[]
// }
// model VerificationToken {
// identifier String
// token String @unique
// expires DateTime
// @@unique([identifier, token])
// }