Skip to content

Commit

Permalink
Multi sig release, 2023-12-31 (#1227)
Browse files Browse the repository at this point in the history
* Comment one test case

* Added fill snapshot round number back

* Removed blockNumber from snapshot in tests

* Fixed migrations to be compatible with removing blockNumber from history

* add project status to getVerificationFormByProjectId query

* Add sent matching fund to total donations of project and total received of users

related to Giveth/giveth-dapps-v2#3386

* Fix test case for adding matching fund to toal donation amount of projects

* Implement qfRoundStats webservice

related to Giveth/giveth-dapps-v2#3250

* Change allProjects webservice to support qfRoundSlug

related to Giveth/giveth-dapps-v2#3250

* Fix test cases to create qfRound

* Fix test cases to create qfRound

* Fix test cases to create qfRound

* Fix test cases to create qfRound

* Fix updateProjectWithVerificationForm

* Revert updateUserTotalReceived() funciton

* Fix updateUserTotalReceived() test case

* Fix updateUserTotalReceived() test case

* Fix mordor testnet node url

* Read node rpc urls from process.env instead of config

* Add log

* Fix etc provider url in github actions config

* Fix AddSlugToQfRound migration

* Remove unused tests

* add safeTransaction to donation logic

* fix uniqueness index on donation table

* comment a network tests

* fix nullability of transactionId

* make nonce nullable for safe donations

* add nullability to nonce in createdonationResolver

* remove undefined clause from joi validations

* Fix insertDonationsFromQfRoundHistory when can not find corosponding address

* Call refreshProjectDonationSummaryView() immediately after insertDonationsFromQfRoundHistory)

* Save non-evm user wallet address capitalization

* Updated the authentication service related address in test.env

* updated auth server in test env

* add validations for multisig donations

* add abis decoder for multisig transactions and parsers

* fetch from and to addresses correctly for multisig validations

* fix native token transfer for multisig transactions

* fix transaction amount in tests for multisig

* fix fromAddress edgecase for multisig

* make params options for transactionData

* Project Solana Address Support (#1200)

* Initial add solana address support to project address

* Added chaintype to graphql validator and project verification form

* Added chainType to token
Refactored project filter query builder
Added tests

* Fixed issue in test graphql query
Added some tests

* Fixed issues with tests

* Revert unwanted changes happend after merge

* Fixed issues happend after merge

* Fixed an issue in setting chainType in projectUpdate

* Revert "Removed snapshot block number" (#1202)

* comment uniqueness migration constraint (#1203)

* graphql allow null for transactionId (#1205)

* Create Solana Donations Integration (#1204)

* modify create donation resolver to handle solana token

* fix backward compatible tests

* add tests to solana donation creation

* add tests for solana resolvers (wip)

* fix solana donation tests and logic

* handle multiple solana tokens (future)

* fix some qfround tests

* add solana native token migration

* Update test/testUtils.ts solana token address

Co-authored-by: Amin Latifi <[email protected]>

* Update migration/data/seedTokens.ts Decimals in Token

Co-authored-by: Amin Latifi <[email protected]>

* Update migration/data/seedTokens.ts

Co-authored-by: Amin Latifi <[email protected]>

* Update src/resolvers/donationResolver.test.ts

Co-authored-by: Amin Latifi <[email protected]>

* solana feedback

* fix seed tokens

* fix solana donation flow and apply code feedback

* remove unnecesary code and improve migration

---------

Co-authored-by: Amin Latifi <[email protected]>

* disable ratelimiter from env (#1212)

Co-authored-by: Carlos <[email protected]>

* Hotfix/solana project address (#1210)

* Changed address invalid message

* Removed unused queries

* Fixed solana address verification problem

* Update master-pipeline.yml

* Verify Solana transactions (#1209)

* Add test cases for verifying solana transactions

related to #1171

* Fix build problems

* Refactor verifying solana transfer transactions

* Add disable cors and rate limiting to staging (#1221)

* disable ratelimiter from env (#1208)

* Write migration file to add missed optimism donations to db (#1213)

* Write migration file to add missed optimism donations to db

related to https://github.com/Giveth/giveth-dapps-v2/issues/3520

* Add another missed donation, make addresses lowercase before put in DB

* Move updating views functions out of the loop

* add missing optimism donation

---------

Co-authored-by: Carlos <[email protected]>

* Update master-pipeline.yml

* disable dapp cors with envs

* Renamed variable

---------

Co-authored-by: CarlosQ96 <[email protected]>
Co-authored-by: mohammadranjbarz <[email protected]>
Co-authored-by: Carlos <[email protected]>
Co-authored-by: Moe Shehab <[email protected]>

* Add test and regex for solana token addresses (#1224)

* add test and regex for solana token addresses

* Upated solana wallet address and programId regex

---------

Co-authored-by: Amin Latifi <[email protected]>

* Hotfix solana transction id validator (#1225)

* Improved solana transction id match regex

* Update solana transaction id regex

---------

Co-authored-by: CarlosQ96 <[email protected]>
Co-authored-by: Amin Latifi <[email protected]>
Co-authored-by: Carlos <[email protected]>
Co-authored-by: Krati Jain <[email protected]>
Co-authored-by: Mateo Daza <[email protected]>
Co-authored-by: Moe Shehab <[email protected]>
  • Loading branch information
7 people authored Jan 1, 2024
1 parent b90d2e9 commit 3a7c89c
Show file tree
Hide file tree
Showing 70 changed files with 8,414 additions and 16,474 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/develop-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ jobs:
OPTIMISTIC_SCAN_API_KEY: ${{ secrets.OPTIMISTIC_SCAN_API_KEY }}
CELO_SCAN_API_KEY: ${{ secrets.CELO_SCAN_API_KEY }}
CELO_ALFAJORES_SCAN_API_KEY: ${{ secrets.CELO_ALFAJORES_SCAN_API_KEY }}
MORDOR_ETC_TESTNET: ${{ secrets.MORDOR_ETC_TESTNET }}
ETC_NODE_HTTP_URL: ${{ secrets.ETC_NODE_HTTP_URL }}
SOLANA_NODE_RPC_URL: ${{ secrets.SOLANA_NODE_RPC_URL }}

publish:
needs: test
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/master-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ jobs:
CELO_ALFAJORES_SCAN_API_KEY: ${{ secrets.CELO_ALFAJORES_SCAN_API_KEY }}
MORDOR_ETC_TESTNET: ${{ secrets.MORDOR_ETC_TESTNET }}
ETC_NODE_HTTP_URL: ${{ secrets.ETC_NODE_HTTP_URL }}
SOLANA_NODE_RPC_URL: ${{ secrets.SOLANA_NODE_RPC_URL }}

publish:
needs: test
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/staging-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,10 @@ jobs:
OPTIMISTIC_SCAN_API_KEY: ${{ secrets.OPTIMISTIC_SCAN_API_KEY }}
CELO_SCAN_API_KEY: ${{ secrets.CELO_SCAN_API_KEY }}
CELO_ALFAJORES_SCAN_API_KEY: ${{ secrets.CELO_ALFAJORES_SCAN_API_KEY }}
MORDOR_ETC_TESTNET: ${{ secrets.MORDOR_ETC_TESTNET }}
ETC_NODE_HTTP_URL: ${{ secrets.ETC_NODE_HTTP_URL }}
DROP_DATABASE: ${{ secrets.DROP_DATABASE }}
SOLANA_NODE_RPC_URL: ${{ secrets.SOLANA_NODE_RPC_URL }}

publish:
needs: test
Expand Down
3 changes: 3 additions & 0 deletions config/example.env
Original file line number Diff line number Diff line change
Expand Up @@ -231,3 +231,6 @@ QF_ROUND_MAX_REWARD=0.2
# Rate limit config
DISABLE_SERVER_RATE_LIMITER=false

DISABLE_SERVER_CORS=false

SOLANA_NODE_RPC_URL=
6 changes: 3 additions & 3 deletions config/test.env
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ THIRD_PARTY_PROJECTS_ADMIN_USER_ID=4
PROJECT_FILTERS_THREADS_POOL_CONCURRENCY=1
PROJECT_FILTERS_THREADS_POOL_NAME=ProjectFiltersThreadPool
PROJECT_FILTERS_THREADS_POOL_SIZE=1
PROJECT_FILTERS_THREADS_POOL_DURATION=600
PROJECT_FILTERS_THREADS_POOL_DURATION=1

# OPTIONAL - force logging to stdout when the value is true
LOG_STDOUT=false
Expand Down Expand Up @@ -194,5 +194,5 @@ MATCHING_FUND_DONATIONS_FROM_ADDRESS=0x6e8873085530406995170Da467010565968C7C62

# Rate Limit config
DISABLE_SERVER_RATE_LIMITER=false


DISABLE_SERVER_CORS=false
SOLANA_NODE_RPC_URL=
33 changes: 33 additions & 0 deletions migration/1700998774661-add_slug_to_qf_round.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { MigrationInterface, QueryRunner } from 'typeorm';

export class AddSlugToQfRound1700998774661 implements MigrationInterface {
async up(queryRunner: QueryRunner): Promise<void> {
// Adding the 'slug' column with a default value
await queryRunner.query(
`ALTER TABLE qf_round ADD COLUMN slug TEXT NOT NULL DEFAULT ''`,
);

// Update the 'slug' column to use the 'id' for existing records
await queryRunner.query(`UPDATE qf_round SET slug = id::text`);

// Add a unique constraint to ensure slug uniqueness
await queryRunner.query(
`ALTER TABLE qf_round ADD CONSTRAINT qf_round_slug_unique UNIQUE (slug)`,
);

// Remove the default empty string now that all slugs have been set
await queryRunner.query(
`ALTER TABLE qf_round ALTER COLUMN slug DROP DEFAULT`,
);
}

async down(queryRunner: QueryRunner): Promise<void> {
// If you need to revert the migration, remove the unique constraint
await queryRunner.query(
`ALTER TABLE qf_round DROP CONSTRAINT qf_round_slug_unique`,
);

// Then drop the 'slug' column
await queryRunner.query(`ALTER TABLE qf_round DROP COLUMN slug`);
}
}
4 changes: 2 additions & 2 deletions migration/1701689359018-add_fields_to_qf_round_history.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class addFieldsToQfRoundHistory1701689359018
"matchingFundPriceUsd" = 1,
"matchingFundCurrency" = 'WXDAI'
WHERE
id = 2 AND "matchingFund" IS NOT NULL;
"qfRoundId" = 2 AND "matchingFund" IS NOT NULL;
`);

Expand All @@ -44,7 +44,7 @@ export class addFieldsToQfRoundHistory1701689359018
"matchingFundPriceUsd" = 1,
"matchingFundCurrency" = 'DAI'
WHERE
id = 4 AND "matchingFund" IS NOT NULL;
"qfRoundId" = 4 AND "matchingFund" IS NOT NULL;
`);
}
Expand Down
23 changes: 23 additions & 0 deletions migration/1701792159998-addSafeTransactionIdToDonation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { MigrationInterface, QueryRunner } from 'typeorm';

export class addSafeTransactionIdToDonation1701792159998
implements MigrationInterface
{
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`
ALTER TABLE donation
ADD COLUMN IF NOT EXISTS "safeTransactionId" character varying DEFAULT null
`,
);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`
ALTER TABLE donation
DROP "safeTransactionId"
`,
);
}
}
17 changes: 17 additions & 0 deletions migration/1701979390554-addnullableTransactionId.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { MigrationInterface, QueryRunner } from 'typeorm';

export class addnullableTransactionId1701979390554
implements MigrationInterface
{
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`ALTER TABLE public.donation ALTER COLUMN "transactionId" DROP NOT NULL`,
);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`ALTER TABLE public.donation ALTER COLUMN "transactionId" SET NOT NULL`,
);
}
}
30 changes: 30 additions & 0 deletions migration/1702374813793-addChainTypeToProjectAddressAndDonation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { MigrationInterface, QueryRunner } from 'typeorm';

export class addChainTypeToProjectAddressAndDonation1702374813793
implements MigrationInterface
{
async up(queryRunner: QueryRunner): Promise<void> {
// Add chainType to projectAddress
await queryRunner.query(
`ALTER TABLE "project_address" ADD "chainType" character varying NOT NULL DEFAULT 'EVM'`,
);
// Add chainType to donation
await queryRunner.query(
`ALTER TABLE "donation" ADD "chainType" character varying NOT NULL DEFAULT 'EVM'`,
);

// Add chainType to token
await queryRunner.query(
`ALTER TABLE "token" ADD "chainType" character varying NOT NULL DEFAULT 'EVM'`,
);

// Update chainType for projectAddress
await queryRunner.query(`UPDATE "project_address" SET "chainType" = 'EVM'`);
// Update chainType for donation
await queryRunner.query(`UPDATE "donation" SET "chainType" = 'EVM'`);
// Update chainType for token
await queryRunner.query(`UPDATE "token" SET "chainType" = 'EVM'`);
}

async down(queryRunner: QueryRunner): Promise<void> {}
}
51 changes: 51 additions & 0 deletions migration/1703044586989-addSolanaToken.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { MigrationInterface, QueryRunner } from 'typeorm';
import { NETWORK_IDS } from '../src/provider';
import { Token } from '../src/entities/token';
import seedTokens from './data/seedTokens';
import { ChainType } from '../src/types/network';
import { SOLANA_SYSTEM_PROGRAM } from '../src/utils/networks';

export class addSolanaToken1703044586989 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.manager.save(
Token,
seedTokens.filter(
token =>
token.address === SOLANA_SYSTEM_PROGRAM &&
token.chainType === ChainType.SOLANA,
),
);
const tokens = await queryRunner.query(
`SELECT * FROM token WHERE "chainType" = $1 AND "address" = $2`,
[ChainType.SOLANA, SOLANA_SYSTEM_PROGRAM],
);
const givethOrganization = (
await queryRunner.query(`SELECT * FROM organization
WHERE label='giveth'`)
)[0];
const traceOrganization = (
await queryRunner.query(`SELECT * FROM organization
WHERE label='trace'`)
)[0];
await queryRunner.query(
`INSERT INTO organization_tokens_token ("tokenId", "organizationId") VALUES ($1, $2), ($1, $3)`,
[tokens[0].id, givethOrganization.id, traceOrganization.id],
);
}

public async down(queryRunner: QueryRunner): Promise<void> {
const tokens = await queryRunner.query(
`SELECT * FROM token WHERE "chainType" = $1 AND "address" = $2`,
[ChainType.SOLANA, SOLANA_SYSTEM_PROGRAM],
);
await queryRunner.query(
`DELETE FROM organization_tokens_token WHERE "tokenId" IN (${tokens
.map(token => token.id)
.join(',')})`,
);
await queryRunner.query(
`DELETE FROM token WHERE "chainType" = $1 AND "address" = $2`,
[ChainType.SOLANA, SOLANA_SYSTEM_PROGRAM],
);
}
}
15 changes: 15 additions & 0 deletions migration/data/seedTokens.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { COINGECKO_TOKEN_IDS } from '../../src/adapters/price/CoingeckoPriceAdapter';
import { NETWORK_IDS } from '../../src/provider';
import { ChainType } from '../../src/types/network';
import { SOLANA_SYSTEM_PROGRAM } from '../../src/utils/networks';

interface ITokenData {
name: string;
Expand All @@ -8,6 +11,8 @@ interface ITokenData {
isGivbackEligible?: boolean;
decimals: number;
networkId: number;
chainType?: ChainType;
coingeckoId?: string;
}
const seedTokens: ITokenData[] = [
// Mainnet tokens
Expand Down Expand Up @@ -1244,6 +1249,16 @@ const seedTokens: ITokenData[] = [
decimals: 18,
networkId: NETWORK_IDS.MORDOR_ETC_TESTNET,
},
// TODO: Add solana token
{
name: 'Solana native token',
symbol: 'SOL',
address: SOLANA_SYSTEM_PROGRAM,
decimals: 9,
networkId: NETWORK_IDS.SOLANA,
chainType: ChainType.SOLANA,
coingeckoId: COINGECKO_TOKEN_IDS.SOLANA,
},
];

export default seedTokens;
Loading

0 comments on commit 3a7c89c

Please sign in to comment.