Skip to content

Commit

Permalink
Merge branch 'staging' into feat/addFillSnapshotRoundBack
Browse files Browse the repository at this point in the history
  • Loading branch information
mohammadranjbarz committed Dec 18, 2023
2 parents d1e720c + 2483566 commit 651d9e2
Show file tree
Hide file tree
Showing 97 changed files with 10,665 additions and 932 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/develop-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ on:
pull_request:
branches:
- develop

jobs:
test:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -64,6 +63,8 @@ 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 }}

publish:
needs: test
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/master-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ on:
pull_request:
branches:
- master

jobs:
test:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -64,6 +63,8 @@ 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 }}

publish:
needs: test
Expand Down
7 changes: 5 additions & 2 deletions .github/workflows/staging-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ jobs:
sleep 1
done
# - name: Restore DB backup
# run: PGPASSWORD=postgres psql -h localhost -p 5443 -U postgres -d givethio < /tmp/backups/givethio-staging/db_backup.sql
- name: Restore DB backup
run: PGPASSWORD=postgres psql -h localhost -p 5443 -U postgres -d givethio < /tmp/backups/givethio-staging/db_backup.sql

- name: Use Node.js
uses: actions/setup-node@v1
Expand Down Expand Up @@ -100,6 +100,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 }}
DROP_DATABASE: ${{ secrets.DROP_DATABASE }}

publish:
needs: test
Expand Down
26 changes: 26 additions & 0 deletions config/example.env
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ GOOGLE_SPREADSHEETS_PRIVATE_KEY=
GOOGLE_SPREADSHEETS_CLIENT_EMAIL=
GOOGLE_PROJECT_EXPORTS_SPREADSHEET_ID=

QF_ROUND_GOOGLE_SPREADSHEETS_PRIVATE_KEY=
QF_ROUND_GOOGLE_SPREADSHEETS_CLIENT_EMAIL=
QF_ROUND_DONATIONS_GOOGLE_SPREADSHEET_ID=

POIGN_ART_SUBGRAPH_URL=https://api.thegraph.com/subgraphs/name/dan13ram/poignart-rinkeby
POIGN_ART_SERVICE_ACTIVE=true
POIGN_ART_RECIPIENT_ADDRESS=0x10E1439455BD2624878b243819E31CfEE9eb721C
Expand Down Expand Up @@ -201,3 +205,25 @@ POWER_BALANCE_AGGREGATOR_ADAPTER=powerBalanceAggregator
#POWER_BALANCE_AGGREGATOR_ADAPTER=mock
NUMBER_OF_BALANCE_AGGREGATOR_BATCH=20

# OPTIONAL - default: 60000 (1 minute
QF_ROUND_ESTIMATED_MATCHING_CACHE_DURATION=60000

# OPTIONAL - default: Every 10 minutes
PROJECT_CAMPAIGNS_CACHE_DURATION=600000

# OPTIONAL - default: *0 */5 * * * ( Every 5 minutes)
CACHE_PROJECT_CAMPAIGNS_CRONJOB_EXPRESSION=0 */5 * * * *

# ETC Node URL
ETC_NODE_HTTP_URL=https://etc.getblock.io/{apiKey}/mainnet
ETC_SCAN_API_URL=https://etc.blockscout.com/api/v1

# MORDOR ETC TESTNET Node URL
MORDOR_ETC_TESTNET_SCAN_API_URL=https://etc-mordor.blockscout.com/api/v1
# https://chainlist.org/chain/63
MORDOR_ETC_TESTNET_NODE_HTTP_URL=https://rpc.mordor.etccooperative.org


# This is the address behind donation.eth
MATCHING_FUND_DONATIONS_FROM_ADDRESS=0x6e8873085530406995170Da467010565968C7C62
QF_ROUND_MAX_REWARD=0.2
24 changes: 23 additions & 1 deletion config/test.env
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ REDIS_PORT=6379
REDIS_PASSWORD=

GIVETH_TRACE_BASE_URL=https://feathers.develop.giveth.io
GIVETH_GIV_PRICES_URL=https://givback.develop.giveth.io/givPrice

PINATA_GATEWAY_ADDRESS=https://giveth.mypinata.cloud

Expand Down Expand Up @@ -154,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 All @@ -171,3 +172,24 @@ OPTIMISM_NODE_HTTP_URL=https://optimism-mainnet.public.blastapi.io
BALANCE_AGGREGATOR_BASE_URL=https://dev.serve.giveth.io/givpower-balance-aggregator
POWER_BALANCE_AGGREGATOR_ADAPTER=mock
NUMBER_OF_BALANCE_AGGREGATOR_BATCH=7


# ! millisecond cache, if we increase cache in test ENV we might get some errors in tests
QF_ROUND_ESTIMATED_MATCHING_CACHE_DURATION=1
# ! millisecond cache, if we increase cache in test ENV we might get some errors in tests
PROJECT_CAMPAIGNS_CACHE_DURATION=1


# OPTIONAL - default: *0 */5 * * * ( Every 5 minutes)
CACHE_PROJECT_CAMPAIGNS_CRONJOB_EXPRESSION=0 */5 * * * *

ETC_SCAN_API_URL=https://etc.blockscout.com/api/v1

MORDOR_ETC_TESTNET_NODE_HTTP_URL=https://rpc.mordor.etccooperative.org
# MORDOR ETC TESTNET Node URL
MORDOR_ETC_TESTNET_SCAN_API_URL=https://etc-mordor.blockscout.com/api/v1

# This is the address behind donation.eth
MATCHING_FUND_DONATIONS_FROM_ADDRESS=0x6e8873085530406995170Da467010565968C7C62


16 changes: 16 additions & 0 deletions migration/1694295208252-AddEligibleNetworksToQfRoundEntity.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { MigrationInterface, QueryRunner, TableColumn } from 'typeorm';

export class AddEligibleNetworksToQfRoundEntity1694295208252
implements MigrationInterface
{
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`
ALTER TABLE public.qf_round
ADD COLUMN IF NOT EXISTS "eligibleNetworks" integer array DEFAULT ARRAY[]::integer[]
`);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.dropColumn('qf_round', 'eligibleNetworks');
}
}
32 changes: 32 additions & 0 deletions migration/1694635872128-AddEligibleNetworksToPreviousQfRounds.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { MigrationInterface, QueryRunner } from 'typeorm';
import config from '../src/config';

export class AddEligibleNetworksToPreviousQfRounds1694635872128
implements MigrationInterface
{
public async up(queryRunner: QueryRunner): Promise<void> {
const environment = config.get('ENVIRONMENT') as string;

// Define the eligible network IDs based on the conditions
const eligibleNetworks =
environment !== 'production'
? [1, 3, 5, 100, 137, 10, 420, 56, 42220, 44787] // Include testnets for staging
: [1, 137, 56, 42220, 100, 10]; // Exclude testnets for non-staging

// Update the "qf_round" table with the new eligibleNetworks values
await queryRunner.query(
`
UPDATE public.qf_round
SET "eligibleNetworks" = $1
`,
[eligibleNetworks],
);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`
UPDATE public.qf_round
SET "eligibleNetworks" = '{}'
`);
}
}
46 changes: 46 additions & 0 deletions migration/1696421249293-AddExternalDonationsFields.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { MigrationInterface, QueryRunner, TableColumn } from 'typeorm';

export class AddExternalDonationsFields1696421249293
implements MigrationInterface
{
public async up(queryRunner: QueryRunner): Promise<void> {
const table = await queryRunner.getTable('donation');
if (!table?.findColumnByName('isExternal')) {
await queryRunner.addColumn(
'donation',
new TableColumn({
name: 'isExternal',
type: 'boolean',
default: false,
}),
);
}

if (!table?.findColumnByName('blockNumber')) {
await queryRunner.addColumn(
'donation',
new TableColumn({
name: 'blockNumber',
type: 'integer',
isNullable: true,
}),
);
}

if (!table?.findColumnByName('origin')) {
await queryRunner.addColumn(
'donation',
new TableColumn({
name: 'origin',
type: 'varchar',
isNullable: true,
}),
);
}
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.dropColumn('donation', 'isExternal');
await queryRunner.dropColumn('donation', 'blockNumber');
}
}
36 changes: 36 additions & 0 deletions migration/1696421249293-add_isStableCoin_field_to_token_table.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { MigrationInterface, QueryRunner } from 'typeorm';

export class addIsStableCoinFieldToTokenTable1696421249293
implements MigrationInterface
{
public async up(queryRunner: QueryRunner): Promise<void> {
// Add the isStableCoin column with a default value of false
await queryRunner.query(`
DO $$
BEGIN
BEGIN
ALTER TABLE token ADD COLUMN "isStableCoin" boolean NOT NULL DEFAULT false;
EXCEPTION
WHEN duplicate_column THEN
-- Handle the error, or just do nothing to skip adding the column.
RAISE NOTICE 'Column "isStableCoin" already exists in "token".';
END;
END $$;
`);

// Update records to set "isStableCoin" to true based on symbol
await queryRunner.query(`
UPDATE token
SET "isStableCoin" = true
WHERE symbol IN ('USDC', 'USDT', 'DAI', 'GLO', 'pyUSD', 'XDAI', 'WXDAI', 'cUSD');
`);
}

public async down(queryRunner: QueryRunner): Promise<void> {
// Remove the "isStableCoin" column
await queryRunner.query(`
ALTER TABLE token
DROP COLUMN "isStableCoin";
`);
}
}
55 changes: 55 additions & 0 deletions migration/1696421249294-Add_ETC_Tokens.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { MigrationInterface, QueryRunner } from 'typeorm';
import { Token } from '../src/entities/token';
import seedTokens from './data/seedTokens';
import { NETWORK_IDS } from '../src/provider';

export class AddETCTokens1696421249294 implements MigrationInterface {
async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.manager.save(
Token,
seedTokens
.filter(token => token.networkId === NETWORK_IDS.ETC)
.map(t => {
t.address = t.address?.toLowerCase();
return t;
}),
);
const tokens = await queryRunner.query(`
SELECT * FROM token
WHERE "networkId" = ${NETWORK_IDS.ETC}
`);
const givethOrganization = (
await queryRunner.query(`SELECT * FROM organization
WHERE label='giveth'`)
)[0];
const traceOrganization = (
await queryRunner.query(`SELECT * FROM organization
WHERE label='trace'`)
)[0];

for (const token of tokens) {
await queryRunner.query(`INSERT INTO organization_tokens_token ("tokenId","organizationId") VALUES
(${token.id}, ${givethOrganization.id}),
(${token.id}, ${traceOrganization.id})
;`);
}
}

async down(queryRunner: QueryRunner): Promise<void> {
const tokens = await queryRunner.query(`
SELECT * FROM token
WHERE "networkId" = ${NETWORK_IDS.ETC}
`);
await queryRunner.query(
`DELETE FROM organization_tokens_token WHERE "tokenId" IN (${tokens
.map(token => token.id)
.join(',')})`,
);
await queryRunner.query(
`
DELETE from token
WHERE "networkId" = ${NETWORK_IDS.ETC}
`,
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { MigrationInterface, QueryRunner } from 'typeorm';
import { Token } from '../src/entities/token';
import seedTokens from './data/seedTokens';
import { NETWORK_IDS } from '../src/provider';

export class AddCryptoCompareIdAndCoingeckoIdToTokenTable1696421249294
implements MigrationInterface
{
async up(queryRunner: QueryRunner): Promise<void> {
// Add the cryptoCompareId and coingeckoId columns with a default value of NULL
await queryRunner.query(`
DO $$
BEGIN
BEGIN
ALTER TABLE token ADD COLUMN "cryptoCompareId" text DEFAULT NULL;
ALTER TABLE token ADD COLUMN "coingeckoId" text DEFAULT NULL;
EXCEPTION
WHEN duplicate_column THEN
-- Handle the error, or just do nothing to skip adding the column.
RAISE NOTICE 'Column "cryptoCompareId" or "coingeckoId already exists in "token".';
END;
END $$;
`);
}

async down(queryRunner: QueryRunner): Promise<void> {
// Remove the "cryptoCompareId" column
await queryRunner.query(`
ALTER TABLE token
DROP COLUMN "cryptoCompareId";
`);

// Remove the "coingeckoId" column
await queryRunner.query(`
ALTER TABLE token
DROP COLUMN "cryptoCompareId";
`);
}
}
Loading

0 comments on commit 651d9e2

Please sign in to comment.