Skip to content
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

Add base chain #1579

Merged
merged 13 commits into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/develop-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ jobs:
CELO_ALFAJORES_SCAN_API_KEY: ${{ secrets.CELO_ALFAJORES_SCAN_API_KEY }}
ARBITRUM_SCAN_API_KEY: ${{ secrets.ARBITRUM_SCAN_API_KEY }}
ARBITRUM_SEPOLIA_SCAN_API_KEY: ${{ secrets.ARBITRUM_SEPOLIA_SCAN_API_KEY }}
BASE_SCAN_API_KEY: ${{ secrets.BASE_SCAN_API_KEY }}
BASE_SEPOLIA_SCAN_API_KEY: ${{ secrets.BASE_SEPOLIA_SCAN_API_KEY }}
MORDOR_ETC_TESTNET: ${{ secrets.MORDOR_ETC_TESTNET }}
ETC_NODE_HTTP_URL: ${{ secrets.ETC_NODE_HTTP_URL }}
SOLANA_TEST_NODE_RPC_URL: ${{ secrets.SOLANA_TEST_NODE_RPC_URL }}
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/master-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ jobs:
CELO_ALFAJORES_SCAN_API_KEY: ${{ secrets.CELO_ALFAJORES_SCAN_API_KEY }}
ARBITRUM_SCAN_API_KEY: ${{ secrets.ARBITRUM_SCAN_API_KEY }}
ARBITRUM_SEPOLIA_SCAN_API_KEY: ${{ secrets.ARBITRUM_SEPOLIA_SCAN_API_KEY }}
BASE_SCAN_API_KEY: ${{ secrets.BASE_SCAN_API_KEY }}
BASE_SEPOLIA_SCAN_API_KEY: ${{ secrets.BASE_SEPOLIA_SCAN_API_KEY }}
MORDOR_ETC_TESTNET: ${{ secrets.MORDOR_ETC_TESTNET }}
ETC_NODE_HTTP_URL: ${{ secrets.ETC_NODE_HTTP_URL }}
DROP_DATABASE: ${{ secrets.DROP_DATABASE_DURING_TEST_PROD }}
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/staging-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ jobs:
CELO_ALFAJORES_SCAN_API_KEY: ${{ secrets.CELO_ALFAJORES_SCAN_API_KEY }}
ARBITRUM_SCAN_API_KEY: ${{ secrets.ARBITRUM_SCAN_API_KEY }}
ARBITRUM_SEPOLIA_SCAN_API_KEY: ${{ secrets.ARBITRUM_SEPOLIA_SCAN_API_KEY }}
BASE_SCAN_API_KEY: ${{ secrets.BASE_SCAN_API_KEY }}
BASE_SEPOLIA_SCAN_API_KEY: ${{ secrets.BASE_SEPOLIA_SCAN_API_KEY }}
MORDOR_ETC_TESTNET: ${{ secrets.MORDOR_ETC_TESTNET }}
ETC_NODE_HTTP_URL: ${{ secrets.ETC_NODE_HTTP_URL }}
DROP_DATABASE: ${{ secrets.DROP_DATABASE_DURING_TEST_STAGING }}
Expand Down
11 changes: 11 additions & 0 deletions config/example.env
Original file line number Diff line number Diff line change
Expand Up @@ -307,3 +307,14 @@ ENABLE_DRAFT_RECURRING_DONATION=true
DRAFT_RECURRING_DONATION_MATCH_EXPIRATION_HOURS=24

OPTIMISTIC_SEPOLIA_SCAN_API_KEY=

BASE_SCAN_API_URL=https://api.basescan.org/api
BASE_SCAN_API_KEY=0000000000000000000000000000000000
BASE_SEPOLIA_SCAN_API_URL=https://api-sepolia.basescan.org/api
BASE_SEPOLIA_SCAN_API_KEY=0000000000000000000000000000000000

# BASE MAINNET
BASE_MAINNET_NODE_HTTP_URL=

# BASE SEPOLIA
BASE_SEPOLIA_NODE_HTTP_URL=
6 changes: 6 additions & 0 deletions config/test.env
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ ARBITRUM_SCAN_API_URL=https://api.arbiscan.io/api
ARBITRUM_SCAN_API_KEY=0000000000000000000000000000000000
ARBITRUM_SEPOLIA_SCAN_API_URL=https://api-sepolia.arbiscan.io/api
ARBITRUM_SEPOLIA_SCAN_API_KEY=0000000000000000000000000000000000

BASE_SCAN_API_URL=https://api.basescan.org/api
BASE_SCAN_API_KEY=0000000000000000000000000000000000
BASE_SEPOLIA_SCAN_API_URL=https://api-sepolia.basescan.org/api
BASE_SEPOLIA_SCAN_API_KEY=0000000000000000000000000000000000

GNOSISSCAN_API_URL=https://api.gnosisscan.io/api
ETHERSCAN_API_KEY=00000000000000000000000000000000
GNOSISSCAN_API_KEY=0000000000000000000000000000000000
Expand Down
55 changes: 55 additions & 0 deletions migration/1716367359560-add_base_chain_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 config from '../src/config';
import { NETWORK_IDS } from '../src/provider';

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

const networkId =
environment === 'production'
? NETWORK_IDS.BASE_MAINNET
: NETWORK_IDS.BASE_SEPOLIA;

await queryRunner.manager.save(
Token,
seedTokens
.filter(token => token.networkId === networkId)
.map(token => {
const t = {
...token,
};
t.address = t.address?.toLowerCase();
delete t.chainType;
return t;
}),
);
const tokens = await queryRunner.query(`
SELECT * FROM token
WHERE "networkId" = ${networkId}
`);
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) {
// Add all Base tokens to Giveth organization
await queryRunner.query(`INSERT INTO organization_tokens_token ("tokenId","organizationId") VALUES
(${token.id}, ${givethOrganization.id}),
(${token.id}, ${traceOrganization.id})
;`);
}
Comment on lines +7 to +49
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure proper transaction handling in the up method.

Consider wrapping the database operations within a transaction to ensure atomicity. This is crucial for maintaining data integrity, especially in production environments.

+ await queryRunner.startTransaction();
  try {
    // existing code...
+   await queryRunner.commitTransaction();
  } catch (error) {
+   await queryRunner.rollbackTransaction();
    throw error;
  }

Committable suggestion was skipped due low confidence.

}

public async down(_queryRunner: QueryRunner): Promise<void> {
//
}
Comment on lines +52 to +54
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider implementing a rollback mechanism in the down method to reverse the changes made by the up method.

}
Loading
Loading