Skip to content

Commit

Permalink
Merge branch 'staging' into setCorrectStreamingDates
Browse files Browse the repository at this point in the history
  • Loading branch information
aminlatifi authored Oct 28, 2024
2 parents d97e4ce + dc067a5 commit 5ab9da7
Show file tree
Hide file tree
Showing 15 changed files with 215 additions and 653 deletions.
9 changes: 7 additions & 2 deletions config/test.env
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ ZKEVM_MAINET_SCAN_API_KEY=0000000000000000000000000000000000
ZKEVM_CARDONA_SCAN_API_URL=https://api-cardona-zkevm.polygonscan.com/api
ZKEVM_CARDONA_SCAN_API_KEY=0000000000000000000000000000000000
# ZKEVM MAINNET we should fill it as Infura doesnt support polygon zkevm, I found this rpc link from https://chainlist.org/chain/1101
ZKEVM_MAINNET_NODE_HTTP_URL=https://polygon-zkevm.drpc.org
ZKEVM_MAINNET_NODE_HTTP_URL=https://zkevm-rpc.com

# ZKEVM CARDONA we should fill it as Infura doesnt support polygon zkevm, I found this rpc link from https://chainlist.org/chain/2442
ZKEVM_CARDONA_NODE_HTTP_URL=https://rpc.cardona.zkevm-rpc.com
Expand All @@ -230,4 +230,9 @@ PRIVADO_VERIFIER_NETWORK_ID=2442

INVERTER_GRAPHQL_ENDPOINT=https://indexer.bigdevenergy.link/a414bf3/v1/graphql

QACC_NETWORK_ID=11155420
QACC_NETWORK_ID=1101

QACC_DONATION_TOKEN_ADDRESS=0x22B21BedDef74FE62F031D2c5c8F7a9F8a4b304D
QACC_DONATION_TOKEN_DECIMALS=18
QACC_DONATION_TOKEN_NAME=Polygon Ecosystem Token
QACC_DONATION_TOKEN_SYMBOL=POL
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@
"start:test": "NODE_ENV=development ts-node-dev --project ./tsconfig.json --respawn ./test.ts",
"serve": "pm2 startOrRestart ecosystem.config.js --node-args='--max-old-space-size=8192'",
"db:migrate:run:test": "NODE_ENV=test npx typeorm-ts-node-commonjs migration:run -d ./src/ormconfig.ts",
"db:migrate:create:test": "NODE_ENV=test npx typeorm-ts-node-commonjs migration:generate migration/$MIGRATION_NAME -d ./src/ormconfig.ts",
"db:migrate:revert:test": "NODE_ENV=test npx typeorm-ts-node-commonjs migration:revert -d ./src/ormconfig.ts",
"db:migrate:run:local": "NODE_ENV=development npx typeorm-ts-node-commonjs migration:run -d ./src/ormconfig.ts",
"db:migrate:create:local": "NODE_ENV=development npx typeorm-ts-node-commonjs migration:generate migration/$MIGRATION_NAME -d ./src/ormconfig.ts",
Expand Down
6 changes: 3 additions & 3 deletions src/entities/donation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,11 @@ export class Donation extends BaseEntity {
@Index()
@Field(_type => QfRound, { nullable: true })
@ManyToOne(_type => QfRound, { eager: true })
qfRound: QfRound;
qfRound?: QfRound | null;

@RelationId((donation: Donation) => donation.qfRound)
@Column({ nullable: true })
qfRoundId: number;
qfRoundId: number | null;

@Index()
@Field(_type => QfRound, { nullable: true })
Expand Down Expand Up @@ -267,7 +267,7 @@ export class Donation extends BaseEntity {

@RelationId((donation: Donation) => donation.earlyAccessRound)
@Column({ nullable: true })
earlyAccessRoundId: number;
earlyAccessRoundId: number | null;

@Field({ nullable: true })
@Column({ type: 'float', nullable: true })
Expand Down
2 changes: 1 addition & 1 deletion src/repositories/donationRepository.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ function findDonationByIdTestCases() {
assert.equal(fetchedDonation?.id, donation.id);
assert.isOk(fetchedDonation?.project);
assert.equal(fetchedDonation?.project.id, project.id);
assert.equal(fetchedDonation?.qfRound.id, qfRound.id);
assert.equal(fetchedDonation?.qfRound?.id, qfRound.id);
});
it('should not return donation with invalid id ', async () => {
const fetchedDonation = await findDonationById(10000000);
Expand Down
10 changes: 7 additions & 3 deletions src/repositories/earlyAccessRoundRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,16 @@ export const findAllEarlyAccessRounds = async (): Promise<

// Find the currently active Early Access Round
export const findActiveEarlyAccessRound = async (
currentDate = new Date(),
date = new Date(),
): Promise<EarlyAccessRound | null> => {
try {
const query = EarlyAccessRound.createQueryBuilder('earlyAccessRound')
.where('earlyAccessRound.startDate <= :currentDate', { currentDate })
.andWhere('earlyAccessRound.endDate >= :currentDate', { currentDate });
.where('earlyAccessRound.startDate <= :date', {
date,
})
.andWhere('earlyAccessRound.endDate >= :date', {
date,
});

return query.getOne();
} catch (error) {
Expand Down
5 changes: 3 additions & 2 deletions src/repositories/projectRoundRecordRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ export async function updateOrCreateProjectRoundRecord(
projectId: number,
qfRoundId?: number | null,
earlyAccessRoundId?: number | null,
): Promise<ProjectRoundRecord> {
): Promise<ProjectRoundRecord | null> {
if (!qfRoundId && !earlyAccessRoundId) {
throw new Error('No round specified on updateOrCreateProjectRoundRecord');
return null;
// throw new Error('No round specified on updateOrCreateProjectRoundRecord');
}
try {
let query = Donation.createQueryBuilder('donation')
Expand Down
14 changes: 10 additions & 4 deletions src/repositories/qfRoundRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,18 @@ export const findArchivedQfRounds = async (
return fullRounds.slice(skip, skip + limit);
};

export const findActiveQfRound = async (
noCache?: boolean,
): Promise<QfRound | null> => {
export const findActiveQfRound = async ({
noCache = false,
date = new Date(),
}: {
noCache?: boolean;
date?: Date;
} = {}): Promise<QfRound | null> => {
const query = QfRound.createQueryBuilder('qfRound')
.where('"isActive" = true')
.andWhere('NOW() BETWEEN "qfRound"."beginDate" AND "qfRound"."endDate"');
.andWhere(':date BETWEEN "qfRound"."beginDate" AND "qfRound"."endDate"', {
date,
});
if (noCache) {
return query.getOne();
}
Expand Down
13 changes: 6 additions & 7 deletions src/resolvers/donationResolver.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ import {
DRAFT_DONATION_STATUS,
DraftDonation,
} from '../entities/draftDonation';
import qacc from '../utils/qacc';
import { QACC_DONATION_TOKEN_SYMBOL } from '../constants/qacc';
import { EarlyAccessRound } from '../entities/earlyAccessRound';
import { ProjectRoundRecord } from '../entities/projectRoundRecord';
Expand Down Expand Up @@ -919,7 +918,7 @@ function createDonationTestCases() {
firstName: 'first name',
}).save();

const user2 = await User.create({
await User.create({
walletAddress: referrerWalletAddress,
loginType: 'wallet',
firstName: 'first name',
Expand Down Expand Up @@ -957,14 +956,14 @@ function createDonationTestCases() {
},
});
// assert.isTrue(donation?.isTokenEligibleForGivback);
assert.equal(donation?.referrerWallet, user2.walletAddress);
assert.isOk(donation?.referralStartTimestamp);
// assert.equal(donation?.referrerWallet, user2.walletAddress);
// assert.isOk(donation?.referralStartTimestamp);
assert.isNotOk(donation?.qfRound);
// assert.isTrue(donation?.earlyAccessRound);
});
it('should create a donation in an active qfRound', async () => {
sinon.stub(qacc, 'isEarlyAccessRound').resolves(false);
try {
await EarlyAccessRound.delete({ id: ea.id });
const project = await saveProjectDirectlyToDb(createProjectData());
const qfRound = await QfRound.create({
isActive: true,
Expand Down Expand Up @@ -1221,8 +1220,8 @@ function createDonationTestCases() {
await qfRound.save();
});
it('should create a donation in an active qfRound, when project is not listed', async () => {
sinon.stub(qacc, 'isEarlyAccessRound').resolves(false);
try {
await EarlyAccessRound.delete({ id: ea.id });
const project = await saveProjectDirectlyToDb(createProjectData());
const qfRound = await QfRound.create({
isActive: true,
Expand Down Expand Up @@ -1293,8 +1292,8 @@ function createDonationTestCases() {
}
});
it('should create a donation in an active qfRound, when project is not verified', async () => {
sinon.stub(qacc, 'isEarlyAccessRound').resolves(false);
try {
await EarlyAccessRound.delete({ id: ea.id });
const project = await saveProjectDirectlyToDb(createProjectData());
const qfRound = await QfRound.create({
isActive: true,
Expand Down
Loading

0 comments on commit 5ab9da7

Please sign in to comment.