-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hotfix add matching funds as donations #1190
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
2c8d77a
Insert donations to db based on distributed funds for qfRound projects
mohammadranjbarz 372f3f3
Empty commit to trigger CI/CD
mohammadranjbarz 5136996
Fix query to just add donation for qfRound histories that have full data
mohammadranjbarz 65fa7ef
Fix typo error
mohammadranjbarz 16e106c
Fix insertDonationsFromQfRoundHistory query
mohammadranjbarz 78be225
Move ens address to constant parameter
mohammadranjbarz 5de0225
Fix integration tests for creating donations with matchingFund data
mohammadranjbarz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import { MigrationInterface, QueryRunner } from 'typeorm'; | ||
|
||
export class addFieldsToQfRoundHistory1701689359018 | ||
implements MigrationInterface | ||
{ | ||
async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(` | ||
ALTER TABLE "qf_round_history" | ||
ADD COLUMN "matchingFundAmount" real , | ||
ADD COLUMN "matchingFundPriceUsd" real , | ||
ADD COLUMN "matchingFundCurrency" text ; | ||
`); | ||
|
||
await queryRunner.query(` | ||
ALTER TABLE "donation" | ||
ADD COLUMN "distributedFundQfRoundId" integer; | ||
|
||
-- If you have a foreign key constraint to enforce the relationship | ||
ALTER TABLE "donation" | ||
ADD CONSTRAINT "FK_donation_qfRound" | ||
FOREIGN KEY ("distributedFundQfRoundId") REFERENCES "qf_round"("id"); | ||
`); | ||
|
||
// These rounds are in Production but I didnt set any condition for that | ||
// because I want this part of code be executed in staging ENV | ||
|
||
// Alpha round in production | ||
await queryRunner.query(` | ||
UPDATE qf_round_history | ||
SET | ||
"matchingFundAmount" = "matchingFund", | ||
"matchingFundPriceUsd" = 1, | ||
"matchingFundCurrency" = 'WXDAI' | ||
WHERE | ||
id = 2 AND "matchingFund" IS NOT NULL; | ||
|
||
`); | ||
|
||
// Optimism round in production | ||
await queryRunner.query(` | ||
UPDATE qf_round_history | ||
SET | ||
"matchingFundAmount" = "matchingFund", | ||
"matchingFundPriceUsd" = 1, | ||
"matchingFundCurrency" = 'DAI' | ||
WHERE | ||
id = 4 AND "matchingFund" IS NOT NULL; | ||
|
||
`); | ||
} | ||
|
||
async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(` | ||
ALTER TABLE "qf_round_history" | ||
DROP COLUMN "matchingFundAmount", | ||
DROP COLUMN "matchingFundPriceUsd", | ||
DROP COLUMN "matchingFundCurrency"; | ||
`); | ||
|
||
await queryRunner.query(` | ||
-- If you added a foreign key constraint, remove it first | ||
ALTER TABLE "donation" | ||
DROP CONSTRAINT IF EXISTS "FK_donation_qfRound"; | ||
|
||
ALTER TABLE "donation" | ||
DROP COLUMN "distributedFundQfRoundId"; | ||
`); | ||
} | ||
} |
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,25 @@ | ||
import { MigrationInterface, QueryRunner } from 'typeorm'; | ||
const donationDotEthAddress = '0x6e8873085530406995170Da467010565968C7C62'; // Address behind donation.eth ENS address; | ||
const matchingFundDonationsFromAddress = | ||
(process.env.MATCHING_FUND_DONATIONS_FROM_ADDRESS as string) || | ||
donationDotEthAddress; | ||
|
||
export class createDonationethUser1701756190381 implements MigrationInterface { | ||
async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(` | ||
INSERT INTO public."user" ("walletAddress", "name", "loginType", "role") | ||
VALUES ('${matchingFundDonationsFromAddress}', 'Donation.eth', 'wallet', 'restricted') | ||
ON CONFLICT ("walletAddress") DO NOTHING | ||
`); | ||
} | ||
|
||
async down(queryRunner: QueryRunner): Promise<void> { | ||
if (!matchingFundDonationsFromAddress) { | ||
throw new Error('Wallet address is not defined in the configuration.'); | ||
} | ||
|
||
await queryRunner.query( | ||
`DELETE FROM public."user" WHERE "walletAddress" = '${matchingFundDonationsFromAddress}'`, | ||
); | ||
} | ||
} |
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why are we hard coding the id to 2?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have some qf rounds already in our DB and they have qfRoundHistory items in DB, they dont have new fields, so I had to put their ids hard coded here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jainkrati