-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathponder.schema.ts
57 lines (51 loc) · 1.75 KB
/
ponder.schema.ts
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
import { onchainTable, index, relations } from "ponder";
export const cohortInformation = onchainTable(
"cohort_information",
(t) => ({
address: t.hex().primaryKey(),
chainId: t.integer().notNull(),
name: t.text().notNull(),
url: t.text(),
balance: t.bigint().notNull(),
}),
);
export const cohortRelations = relations(cohortInformation, ({ many }) => ({
builders: many(cohortBuilder),
withdrawals: many(cohortWithdrawal),
}));
export const cohortBuilder = onchainTable(
"cohort_builder",
(t) => ({
id: t.text().primaryKey(),
address: t.hex().notNull(),
amount: t.real().notNull(),
cohortContractAddress: t.hex().notNull(),
timestamp: t.bigint().notNull(),
ens: t.text(),
}),
(table) => ({
cohortAddressIdx: index().on(table.cohortContractAddress),
}),
);
export const buildersRelations = relations(cohortBuilder, ({ one }) => ({
cohort: one(cohortInformation, { fields: [cohortBuilder.cohortContractAddress], references: [cohortInformation.address] }),
}));
export const cohortWithdrawal = onchainTable(
"cohort_withdrawal",
(t) => ({
id: t.text().primaryKey(),
builder: t.hex().notNull(),
cohortBuilder: t.text().notNull(),
amount: t.real().notNull(),
cohortContractAddress: t.hex().notNull(),
reason: t.text().notNull(),
timestamp: t.bigint().notNull(),
}),
(table) => ({
cohortAddressIdx: index().on(table.cohortContractAddress),
}),
);
export const withdrawalsRelations = relations(cohortWithdrawal, ({ one }) => ({
cohort: one(cohortInformation, { fields: [cohortWithdrawal.cohortContractAddress], references: [cohortInformation.address] }),
cohortBuilder: one(cohortBuilder, { fields: [cohortWithdrawal.cohortBuilder], references: [cohortBuilder.id] }),
}));