-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix: remove memo for project verification managing funds * fix: remove memo for project verification managing funds * fix: getDraftDonationById bug (toWalletMemo can be null) * fix: add memo for stellar project address uniqueness * fix: add memo for manage address validation * fix: add duplicate address error message for stellar * fix: linter error * add index for project stellar address * eslint error * fix: case when owner donate to his own peoject (Stellar chain) * fix: add calculateGivbackFactor to Stellar cron job * feat: register secondary donation * running migration to set project banners appropriately for endaoment … (#1778) * running migration to set project banners appropriately for endaoment projects * chore: correcting tab spaces for syntax * fix: linter errors * Modify add banner to endaoment projects migration (#1791) related to #1600 * Fix lint errors * Fix running tests * Fix projectResolver test cases * Fix donationResolver test cases * skip should renew the expiration date of the draft donation test case --------- Co-authored-by: Hrithik Sampson <[email protected]> Co-authored-by: mohammadranjbarz <[email protected]> * fix: remove adding secondary donation logic --------- Co-authored-by: Meriem-BM <[email protected]> Co-authored-by: HrithikSampson <[email protected]> Co-authored-by: Hrithik Sampson <[email protected]>
- Loading branch information
1 parent
1c3a62c
commit 082848e
Showing
15 changed files
with
217 additions
and
36 deletions.
There are no files selected for viewing
101 changes: 101 additions & 0 deletions
101
migration/1724368995904-add_banner_endaoment_projects.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
import { MigrationInterface, QueryRunner } from 'typeorm'; | ||
import { endaomentProjects } from './data/importedEndaomentProjects'; | ||
import { endaomentProjectCategoryMapping } from './data/endaomentProjectCategoryMapping'; | ||
import { NETWORK_IDS } from '../src/provider'; | ||
|
||
export class AddBannerEndaomentProjects1724368995904 | ||
implements MigrationInterface | ||
{ | ||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
const imageCategoryMapping = { | ||
'Public Goods': 'community', | ||
'Peace & Justice': 'community', | ||
'Sustainable Cities & Communities': 'nature', | ||
Housing: 'community', | ||
'Social Services': 'community', | ||
'Family & Children': 'community', | ||
'Health Care': 'community', | ||
'Registered Non-profits': 'non-profit', | ||
Research: 'education', | ||
'Mental Health': 'health-wellness', | ||
Animals: 'nature', | ||
Nutrition: 'health-wellness', | ||
Religious: 'community', | ||
Art: 'art-culture', | ||
Food: 'community', | ||
'Disaster Relief': 'non-profit', | ||
'Conservation & Biodiversity': 'nature', | ||
Education: 'education', | ||
'Industry & Innovation': 'economics-infrastructure', | ||
'Financial Services': 'finance', | ||
Schooling: 'education', | ||
Inclusion: 'equality', | ||
Climate: 'nature', | ||
'Water & Sanitation': 'community', | ||
Tech: 'technology', | ||
Employment: 'finance', | ||
Infrastructure: 'economics-infrastructure', | ||
'International Aid': 'non-profit', | ||
Other: '1', | ||
Recreation: 'community', | ||
Culture: 'art-culture', | ||
Recycling: 'nature', | ||
Agriculture: 'nature', | ||
Grassroots: 'community', | ||
'BIPOC Communities': 'equality', | ||
Fundraising: 'non-profit', | ||
'Registred Non-profits': 'non-profit', | ||
'Gender Equality': 'equality', | ||
}; | ||
|
||
for (const project of endaomentProjects) { | ||
const mainnetAddress = project.mainnetAddress; | ||
const projectAddresses = await queryRunner.query( | ||
`SELECT * FROM project_address WHERE LOWER(address) = $1 AND "networkId" = $2 LIMIT 1`, | ||
[mainnetAddress!.toLowerCase(), NETWORK_IDS.MAIN_NET], | ||
); | ||
|
||
const projectAddress = await projectAddresses?.[0]; | ||
|
||
if (!projectAddress) { | ||
// eslint-disable-next-line no-console | ||
console.log(`Could not find project address for ${mainnetAddress}`); | ||
continue; | ||
} | ||
|
||
// Insert the project-category relationship in a single query | ||
const getCategoryNames = (nteeCode: string): string[] => { | ||
const mapping = endaomentProjectCategoryMapping.find( | ||
category => category.nteeCode === nteeCode, | ||
); | ||
return mapping | ||
? [ | ||
mapping.category1, | ||
mapping.category2, | ||
mapping.category3 || '', | ||
mapping.category4 || '', | ||
].filter(Boolean) | ||
: []; | ||
}; | ||
if (!project.nteeCode) { | ||
// eslint-disable-next-line no-console | ||
console.log(`Could not find nteeCode for ${mainnetAddress}`); | ||
continue; | ||
} | ||
const categoryNames = getCategoryNames(String(project.nteeCode)); | ||
const bannerImage = `/images/defaultProjectImages/${imageCategoryMapping[categoryNames[1]] || '1'}.png`; | ||
await queryRunner.query(`UPDATE project SET image = $1 WHERE id = $2`, [ | ||
bannerImage, | ||
projectAddress.projectId, | ||
]); | ||
// eslint-disable-next-line no-console | ||
console.log( | ||
`Updated project ${projectAddress.projectId} with image ${bannerImage}`, | ||
); | ||
} | ||
} | ||
|
||
public async down(_queryRunner: QueryRunner): Promise<void> { | ||
// No down migration | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
migration/1725188424424-UniqueProjectAdressWithMomoForStellar.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { MigrationInterface, QueryRunner } from 'typeorm'; | ||
|
||
export class UniqueProjectAdressWithMomoForStellar1725188424424 | ||
implements MigrationInterface | ||
{ | ||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(` | ||
CREATE UNIQUE INDEX unique_stellar_address | ||
ON project_address (address, memo) | ||
WHERE "chainType" = 'STELLAR'; | ||
`); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(` | ||
DROP INDEX unique_stellar_address; | ||
`); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.