diff --git a/migration/1727434746651-addRoundCaps.ts b/migration/1727434746651-addRoundCaps.ts index cef32540d..60a18f4b6 100644 --- a/migration/1727434746651-addRoundCaps.ts +++ b/migration/1727434746651-addRoundCaps.ts @@ -10,33 +10,21 @@ export class AddRoundCaps1727434746651 implements MigrationInterface { await queryRunner.query( `ALTER TABLE "qf_round" ADD "roundUSDCapPerUserPerProject" integer`, ); - await queryRunner.query( - `ALTER TABLE "qf_round" ADD "POLPriceAtRoundStart" numeric(18,8)`, - ); await queryRunner.query( `ALTER TABLE "early_access_round" ADD "roundUSDCapPerProject" integer`, ); await queryRunner.query( `ALTER TABLE "early_access_round" ADD "roundUSDCapPerUserPerProject" integer`, ); - await queryRunner.query( - `ALTER TABLE "early_access_round" ADD "POLPriceAtRoundStart" numeric(18,8)`, - ); } public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query( - `ALTER TABLE "early_access_round" DROP COLUMN "POLPriceAtRoundStart"`, - ); await queryRunner.query( `ALTER TABLE "early_access_round" DROP COLUMN "roundUSDCapPerUserPerProject"`, ); await queryRunner.query( `ALTER TABLE "early_access_round" DROP COLUMN "roundUSDCapPerProject"`, ); - await queryRunner.query( - `ALTER TABLE "qf_round" DROP COLUMN "POLPriceAtRoundStart"`, - ); await queryRunner.query( `ALTER TABLE "qf_round" DROP COLUMN "roundUSDCapPerUserPerProject"`, ); diff --git a/src/entities/earlyAccessRound.ts b/src/entities/earlyAccessRound.ts index 336f6b914..50be558b1 100644 --- a/src/entities/earlyAccessRound.ts +++ b/src/entities/earlyAccessRound.ts @@ -7,7 +7,7 @@ import { UpdateDateColumn, Index, } from 'typeorm'; -import { Field, ID, ObjectType, Int, Float } from 'type-graphql'; +import { Field, ID, ObjectType, Int } from 'type-graphql'; @Entity() @ObjectType() @@ -37,10 +37,6 @@ export class EarlyAccessRound extends BaseEntity { @Column({ nullable: true }) roundUSDCapPerUserPerProject?: number; - @Field(() => Float, { nullable: true }) - @Column({ type: 'decimal', precision: 18, scale: 8, nullable: true }) - POLPriceAtRoundStart?: number; - @Field(() => Date) @CreateDateColumn() createdAt: Date; diff --git a/src/entities/qfRound.ts b/src/entities/qfRound.ts index 436a75039..6a6ab74cb 100644 --- a/src/entities/qfRound.ts +++ b/src/entities/qfRound.ts @@ -130,10 +130,6 @@ export class QfRound extends BaseEntity { @Column({ nullable: true }) roundUSDCapPerUserPerProject?: number; - @Field(() => Float, { nullable: true }) - @Column({ type: 'decimal', precision: 18, scale: 8, nullable: true }) - POLPriceAtRoundStart?: number; - // only projects with status active can be listed automatically isEligibleNetwork(donationNetworkId: number): boolean { // when not specified, all are valid diff --git a/src/repositories/earlyAccessRoundRepository.test.ts b/src/repositories/earlyAccessRoundRepository.test.ts index 22308779a..9867b0f56 100644 --- a/src/repositories/earlyAccessRoundRepository.test.ts +++ b/src/repositories/earlyAccessRoundRepository.test.ts @@ -42,7 +42,7 @@ describe('EarlyAccessRound Repository Test Cases', () => { endDate: new Date('2024-09-05'), roundUSDCapPerProject: 1000000, roundUSDCapPerUserPerProject: 50000, - POLPriceAtRoundStart: 0.12345678, + tokenPrice: 0.12345678, }; const savedRound = await saveRoundDirectlyToDb(roundData); @@ -61,9 +61,7 @@ describe('EarlyAccessRound Repository Test Cases', () => { expect(savedRound.roundUSDCapPerUserPerProject).to.equal( roundData.roundUSDCapPerUserPerProject, ); - expect(savedRound.POLPriceAtRoundStart).to.equal( - roundData.POLPriceAtRoundStart, - ); + expect(savedRound.tokenPrice).to.equal(roundData.tokenPrice); }); it('should find all Early Access Rounds', async () => { @@ -74,7 +72,7 @@ describe('EarlyAccessRound Repository Test Cases', () => { endDate: new Date('2024-09-05'), roundUSDCapPerProject: 1000000, roundUSDCapPerUserPerProject: 50000, - POLPriceAtRoundStart: 0.12345678, + tokenPrice: 0.12345678, }); await saveRoundDirectlyToDb({ roundNumber: 2, @@ -82,7 +80,7 @@ describe('EarlyAccessRound Repository Test Cases', () => { endDate: new Date('2024-09-10'), roundUSDCapPerProject: 2000000, roundUSDCapPerUserPerProject: 100000, - POLPriceAtRoundStart: 0.23456789, + tokenPrice: 0.23456789, }); const rounds = await findAllEarlyAccessRounds(); @@ -92,7 +90,7 @@ describe('EarlyAccessRound Repository Test Cases', () => { expect(rounds[0]).to.be.an.instanceof(EarlyAccessRound); expect(rounds[0].roundUSDCapPerProject).to.equal(1000000); expect(rounds[1].roundUSDCapPerUserPerProject).to.equal(100000); - expect(Number(rounds[0].POLPriceAtRoundStart)).to.equal(0.12345678); + expect(rounds[0].tokenPrice).to.equal(0.12345678); }); it('should find the active Early Access Round', async () => { @@ -102,7 +100,7 @@ describe('EarlyAccessRound Repository Test Cases', () => { endDate: new Date(new Date().setDate(new Date().getDate() + 1)), // tomorrow roundUSDCapPerProject: 500000, roundUSDCapPerUserPerProject: 25000, - POLPriceAtRoundStart: 0.11111111, + tokenPrice: 0.11111111, }; const inactiveRoundData = { @@ -111,7 +109,7 @@ describe('EarlyAccessRound Repository Test Cases', () => { endDate: new Date(new Date().getDate() + 2), roundUSDCapPerProject: 1000000, roundUSDCapPerUserPerProject: 50000, - POLPriceAtRoundStart: 0.22222222, + tokenPrice: 0.22222222, }; // Save both active and inactive rounds @@ -134,9 +132,7 @@ describe('EarlyAccessRound Repository Test Cases', () => { expect(activeRound?.roundUSDCapPerUserPerProject).to.equal( activeRoundData.roundUSDCapPerUserPerProject, ); - expect(Number(activeRound?.POLPriceAtRoundStart)).to.equal( - activeRoundData.POLPriceAtRoundStart, - ); + expect(activeRound?.tokenPrice).to.equal(activeRoundData.tokenPrice); }); it('should return null when no active Early Access Round is found', async () => { diff --git a/src/repositories/qfRoundRepository.test.ts b/src/repositories/qfRoundRepository.test.ts index 5dd119abf..aedfa76f0 100644 --- a/src/repositories/qfRoundRepository.test.ts +++ b/src/repositories/qfRoundRepository.test.ts @@ -408,19 +408,18 @@ function findQfRoundByIdTestCases() { slug: new Date().getTime().toString(), beginDate: new Date(), endDate: moment().add(1, 'days').toDate(), - roundUSDCapPerProject: 500000, // New field - roundUSDCapPerUserPerProject: 25000, // New field - POLPriceAtRoundStart: 0.12345678, // New field + roundUSDCapPerProject: 500000, + roundUSDCapPerUserPerProject: 25000, + tokenPrice: 0.12345678, }); await qfRound.save(); const result = await findQfRoundById(qfRound.id); assert.equal(result?.id, qfRound.id); - // Additional assertions for the new fields assert.equal(result?.roundUSDCapPerProject, 500000); assert.equal(result?.roundUSDCapPerUserPerProject, 25000); - assert.equal(Number(result?.POLPriceAtRoundStart), 0.12345678); + assert.equal(result?.tokenPrice, 0.12345678); qfRound.isActive = false; await qfRound.save(); @@ -435,19 +434,17 @@ function findQfRoundByIdTestCases() { slug: new Date().getTime().toString(), beginDate: new Date(), endDate: moment().subtract(1, 'days').toDate(), - roundUSDCapPerProject: 500000, // New field - roundUSDCapPerUserPerProject: 25000, // New field - POLPriceAtRoundStart: 0.12345678, // New field + roundUSDCapPerProject: 500000, + roundUSDCapPerUserPerProject: 25000, + tokenPrice: 0.12345678, }); await qfRound.save(); const result = await findQfRoundById(qfRound.id); assert.equal(result?.id, qfRound.id); - - // Additional assertions for the new fields assert.equal(result?.roundUSDCapPerProject, 500000); assert.equal(result?.roundUSDCapPerUserPerProject, 25000); - assert.equal(Number(result?.POLPriceAtRoundStart), 0.12345678); + assert.equal(result?.tokenPrice, 0.12345678); }); it('should return null if id is invalid', async () => { @@ -466,19 +463,17 @@ function findQfRoundBySlugTestCases() { slug: new Date().getTime().toString(), beginDate: new Date(), endDate: moment().add(1, 'days').toDate(), - roundUSDCapPerProject: 500000, // New field - roundUSDCapPerUserPerProject: 25000, // New field - POLPriceAtRoundStart: 0.12345678, // New field + roundUSDCapPerProject: 500000, + roundUSDCapPerUserPerProject: 25000, + tokenPrice: 0.12345678, }); await qfRound.save(); const result = await findQfRoundBySlug(qfRound.slug); assert.equal(result?.slug, qfRound.slug); - - // Additional assertions for the new fields assert.equal(result?.roundUSDCapPerProject, 500000); assert.equal(result?.roundUSDCapPerUserPerProject, 25000); - assert.equal(Number(result?.POLPriceAtRoundStart), 0.12345678); + assert.equal(result?.tokenPrice, 0.12345678); qfRound.isActive = false; await qfRound.save(); @@ -493,19 +488,17 @@ function findQfRoundBySlugTestCases() { slug: new Date().getTime().toString(), beginDate: new Date(), endDate: moment().subtract(1, 'days').toDate(), - roundUSDCapPerProject: 500000, // New field - roundUSDCapPerUserPerProject: 25000, // New field - POLPriceAtRoundStart: 0.12345678, // New field + roundUSDCapPerProject: 500000, + roundUSDCapPerUserPerProject: 25000, + tokenPrice: 0.12345678, }); await qfRound.save(); const result = await findQfRoundById(qfRound.id); assert.equal(result?.id, qfRound.id); - - // Additional assertions for the new fields assert.equal(result?.roundUSDCapPerProject, 500000); assert.equal(result?.roundUSDCapPerUserPerProject, 25000); - assert.equal(Number(result?.POLPriceAtRoundStart), 0.12345678); + assert.equal(result?.tokenPrice, 0.12345678); }); it('should return null if slug is invalid', async () => { diff --git a/src/resolvers/roundsResolver.test.ts b/src/resolvers/roundsResolver.test.ts index cc26c4ab9..c89e40308 100644 --- a/src/resolvers/roundsResolver.test.ts +++ b/src/resolvers/roundsResolver.test.ts @@ -73,7 +73,7 @@ function fetchAllRoundsTestCases() { endDate: moment().add(10, 'days').toDate(), roundUSDCapPerProject: 500000, // Nullable field roundUSDCapPerUserPerProject: 25000, // Nullable field - POLPriceAtRoundStart: 0.12345678, // Nullable field + tokenPrice: 0.12345678, // Nullable field }).save(); const qfRound2 = await QfRound.create({ @@ -114,10 +114,10 @@ function fetchAllRoundsTestCases() { // Verify nullable fields assert.equal(qfRounds[1].roundUSDCapPerProject, 500000); assert.equal(qfRounds[1].roundUSDCapPerUserPerProject, 25000); - assert.equal(Number(qfRounds[1].POLPriceAtRoundStart), 0.12345678); + assert.equal(qfRounds[1].tokenPrice, 0.12345678); assert.isNull(qfRounds[0].roundUSDCapPerProject); assert.isNull(qfRounds[0].roundUSDCapPerUserPerProject); - assert.isNull(qfRounds[0].POLPriceAtRoundStart); + assert.isNull(qfRounds[0].tokenPrice); }); } @@ -162,7 +162,7 @@ function fetchActiveRoundTestCases() { endDate: moment().add(2, 'days').toDate(), roundUSDCapPerProject: 500000, roundUSDCapPerUserPerProject: 25000, - POLPriceAtRoundStart: 0.12345678, + tokenPrice: 0.12345678, }).save(); // Create a non-active QF round @@ -176,7 +176,7 @@ function fetchActiveRoundTestCases() { isActive: false, roundUSDCapPerProject: 100000, roundUSDCapPerUserPerProject: 5000, - POLPriceAtRoundStart: 0.54321, + tokenPrice: 0.54321, }).save(); // Query for the active round @@ -194,7 +194,7 @@ function fetchActiveRoundTestCases() { ); assert.equal(response.activeRound.roundUSDCapPerProject, 500000); assert.equal(response.activeRound.roundUSDCapPerUserPerProject, 25000); - assert.equal(Number(response.activeRound.POLPriceAtRoundStart), 0.12345678); + assert.equal(response.activeRound.tokenPrice, 0.12345678); }); it('should return the currently active QF round and no active Early Access round', async () => { @@ -216,7 +216,7 @@ function fetchActiveRoundTestCases() { isActive: true, roundUSDCapPerProject: 500000, roundUSDCapPerUserPerProject: 25000, - POLPriceAtRoundStart: 0.12345678, + tokenPrice: 0.12345678, }).save(); // Query for the active round @@ -231,7 +231,7 @@ function fetchActiveRoundTestCases() { assert.equal(response.activeRound.name, activeQfRound.name); assert.equal(response.activeRound.roundUSDCapPerProject, 500000); assert.equal(response.activeRound.roundUSDCapPerUserPerProject, 25000); - assert.equal(Number(response.activeRound.POLPriceAtRoundStart), 0.12345678); + assert.equal(response.activeRound.tokenPrice, 0.12345678); }); it('should return null when there are no active rounds', async () => { diff --git a/test/graphqlQueries.ts b/test/graphqlQueries.ts index 7d6637767..ff5c6cf9c 100644 --- a/test/graphqlQueries.ts +++ b/test/graphqlQueries.ts @@ -2053,7 +2053,7 @@ export const fetchAllRoundsQuery = ` updatedAt roundUSDCapPerProject roundUSDCapPerUserPerProject - POLPriceAtRoundStart + tokenPrice } ... on QfRound { name @@ -2063,7 +2063,7 @@ export const fetchAllRoundsQuery = ` endDate roundUSDCapPerProject roundUSDCapPerUserPerProject - POLPriceAtRoundStart + tokenPrice } } } @@ -2081,7 +2081,7 @@ export const fetchActiveRoundQuery = ` updatedAt roundUSDCapPerProject roundUSDCapPerUserPerProject - POLPriceAtRoundStart + tokenPrice } ... on QfRound { name @@ -2091,7 +2091,7 @@ export const fetchActiveRoundQuery = ` endDate roundUSDCapPerProject roundUSDCapPerUserPerProject - POLPriceAtRoundStart + tokenPrice } } }