Skip to content

Commit 5402ea3

Browse files
gravityblasthussedevthelostone-mc
authored
celo starting blocks + allow null metatada + add totalDistributed (#570)
* update celo starting blocks * allow null metadata and add totalDistributed to rounds * fix tests * upgrade schema version * add EasyRPGFStrategy ABI --------- Co-authored-by: Huss Martinez <[email protected]> Co-authored-by: Aditya Anand M C <[email protected]>
1 parent d858ffc commit 5402ea3

13 files changed

+464
-18
lines changed

src/config.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ type CoingeckoSupportedChainId =
1919
| 42
2020
| 42220;
2121

22-
const CHAIN_DATA_VERSION = "70";
22+
const CHAIN_DATA_VERSION = "71";
2323

2424
export type Token = {
2525
code: string;
@@ -1643,12 +1643,12 @@ const CHAINS: Chain[] = [
16431643
{
16441644
contractName: "AlloV2/Registry/V1",
16451645
address: "0x4aacca72145e1df2aec137e1f3c5e3d75db8b5f3",
1646-
fromBlock: 25005539,
1646+
fromBlock: 22257475,
16471647
},
16481648
{
16491649
contractName: "AlloV2/Allo/V1",
16501650
address: "0x1133eA7Af70876e64665ecD07C0A0476d09465a1",
1651-
fromBlock: 25005539,
1651+
fromBlock: 22258079,
16521652
},
16531653
],
16541654
},

src/database/changeset.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,12 @@ export type DataChange =
8181
roundId: Address;
8282
amountInUsd: number;
8383
}
84+
| {
85+
type: "IncrementRoundTotalDistributed";
86+
chainId: ChainId;
87+
roundId: string;
88+
amount: bigint;
89+
}
8490
| {
8591
type: "IncrementApplicationDonationStats";
8692
chainId: ChainId;

src/database/index.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,18 @@ export class Database {
470470
break;
471471
}
472472

473+
case "IncrementRoundTotalDistributed": {
474+
await this.#db
475+
.updateTable("rounds")
476+
.set((eb) => ({
477+
totalDistributed: eb("totalDistributed", "+", change.amount),
478+
}))
479+
.where("chainId", "=", change.chainId)
480+
.where("id", "=", change.roundId)
481+
.execute();
482+
break;
483+
}
484+
473485
case "IncrementApplicationDonationStats": {
474486
await this.#db
475487
.updateTable("applications")

src/database/migrate.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@ export async function migrate<T>(db: Kysely<T>, schemaName: string) {
3737
.addPrimaryKeyConstraint("projects_pkey", ["id", "chainId"])
3838
.execute();
3939

40+
await schema
41+
.createIndex("idx_projects_metadata_not_null")
42+
.on("projects")
43+
.columns(["metadata"])
44+
.where(sql.ref("metadata"), "is not", null)
45+
.execute();
46+
4047
await schema
4148
.createTable("pending_project_roles")
4249
.addColumn("id", "serial", (col) => col.primaryKey())
@@ -126,6 +133,7 @@ export async function migrate<T>(db: Kysely<T>, schemaName: string) {
126133
.addColumn("totalAmountDonatedInUSD", "real")
127134
.addColumn("totalDonationsCount", "integer")
128135
.addColumn("uniqueDonorsCount", "integer")
136+
.addColumn("totalDistributed", BIGINT_TYPE, (col) => col.defaultTo("0"))
129137

130138
.addPrimaryKeyConstraint("rounds_pkey", ["id", "chainId"])
131139
.execute();
@@ -142,6 +150,13 @@ export async function migrate<T>(db: Kysely<T>, schemaName: string) {
142150
.columns(["adminRole"])
143151
.execute();
144152

153+
await schema
154+
.createIndex("idx_rounds_round_metadata_not_null")
155+
.on("rounds")
156+
.columns(["roundMetadata"])
157+
.where(sql.ref("round_metadata"), "is not", null)
158+
.execute();
159+
145160
await schema
146161
.createTable("pending_round_roles")
147162
.addColumn("id", "serial", (col) => col.primaryKey())

src/database/schema.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export type RoundTable = {
4545
fundedAmountInUsd: number;
4646
applicationMetadataCid: string;
4747
applicationMetadata: unknown | null;
48-
roundMetadataCid: string;
48+
roundMetadataCid: string | null;
4949
roundMetadata: unknown;
5050
applicationsStartTime: Date | null;
5151
applicationsEndTime: Date | null;
@@ -56,6 +56,7 @@ export type RoundTable = {
5656
updatedAtBlock: bigint;
5757
totalAmountDonatedInUsd: number;
5858
totalDonationsCount: number;
59+
totalDistributed: bigint;
5960
uniqueDonorsCount: number;
6061
managerRole: string;
6162
adminRole: string;

src/deprecatedJsonDatabase.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ export type DeprecatedRound = {
9999
uniqueContributors: number;
100100
applicationMetaPtr: string;
101101
applicationMetadata: unknown | null;
102-
metaPtr: string;
102+
metaPtr: string | null;
103103
metadata: {
104104
name: string;
105105
quadraticFundingConfig?: {

0 commit comments

Comments
 (0)