Skip to content

Commit

Permalink
feat: remove RPC and subgraph URLs from chains package
Browse files Browse the repository at this point in the history
  • Loading branch information
therealemjy committed Dec 3, 2024
1 parent 5bb2836 commit 564731a
Show file tree
Hide file tree
Showing 19 changed files with 261 additions and 443 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/cd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ concurrency:
group: ${{ github.ref }}
cancel-in-progress: true

env:
VITE_ENV: "ci"
CODEGEN_UNRESTRICTED_NODE_REAL_API_KEY: ${{ secrets.CODEGEN_UNRESTRICTED_NODE_REAL_API_KEY }}
CODEGEN_UNRESTRICTED_THE_GRAPH_API_KEY: ${{ secrets.CODEGEN_UNRESTRICTED_THE_GRAPH_API_KEY }}

jobs:
release:
runs-on: ubuntu-latest
Expand All @@ -28,6 +33,9 @@ jobs:
cache: "yarn"

- name: Install dependencies
env:
CODEGEN_UNRESTRICTED_NODE_REAL_API_KEY: ${{ secrets.CODEGEN_UNRESTRICTED_NODE_REAL_API_KEY }}
CODEGEN_UNRESTRICTED_THE_GRAPH_API_KEY: ${{ secrets.CODEGEN_UNRESTRICTED_THE_GRAPH_API_KEY }}
run: yarn

# Bump package versions based on changesets and commit changes to the main branch
Expand Down
10 changes: 6 additions & 4 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@ name: Tests and Checks

on: [pull_request]

env:
VITE_ENV: "ci"
NODE_OPTIONS: "--max_old_space_size=4096"

concurrency:
group: ${{ github.ref }}
cancel-in-progress: true

env:
NODE_OPTIONS: "--max_old_space_size=4096"
VITE_ENV: "ci"
CODEGEN_UNRESTRICTED_NODE_REAL_API_KEY: ${{ secrets.CODEGEN_UNRESTRICTED_NODE_REAL_API_KEY }}
CODEGEN_UNRESTRICTED_THE_GRAPH_API_KEY: ${{ secrets.CODEGEN_UNRESTRICTED_THE_GRAPH_API_KEY }}

jobs:
checks:
runs-on: ubuntu-22.04
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ build
out-tsc
out
generated
.env.generated.co

# Local environment variables
.env
Expand Down
76 changes: 7 additions & 69 deletions apps/evm/.env.template
Original file line number Diff line number Diff line change
@@ -1,81 +1,19 @@
# Environment

VITE_NETWORK=testnet
VITE_ENV=local

# Network-specific

## BSC mainnet

# BSC mainnet
VITE_RPC_HTTP_URL_BSC_MAINNET=
VITE_SUBGRAPH_MARKETS_URL_BSC_MAINNET=
VITE_SUBGRAPH_GOVERNANCE_URL_BSC_MAINNET=

## BSC testnet
VITE_RPC_HTTP_URL_BSC_TESTNET=
VITE_SUBGRAPH_MARKETS_URL_BSC_TESTNET=
VITE_SUBGRAPH_GOVERNANCE_URL_BSC_TESTNET=

## Ethereum
VITE_RPC_HTTP_URL_ETHEREUM=
VITE_SUBGRAPH_MARKETS_URL_ETHEREUM=
VITE_SUBGRAPH_GOVERNANCE_URL_ETHEREUM=

## Sepolia
VITE_RPC_HTTP_URL_SEPOLIA=
VITE_SUBGRAPH_MARKETS_URL_SEPOLIA=
VITE_SUBGRAPH_GOVERNANCE_URL_SEPOLIA=

## opBNB mainnet
VITE_RPC_HTTP_URL_OPBNB_MAINNET=
VITE_SUBGRAPH_MARKETS_URL_OPBNB_MAINNET=
VITE_SUBGRAPH_GOVERNANCE_URL_OPBNB_MAINNET=

## opBNB testnet
VITE_RPC_HTTP_URL_OPBNB_TESTNET=
VITE_SUBGRAPH_MARKETS_URL_OPBNB_TESTNET=
VITE_SUBGRAPH_GOVERNANCE_URL_OPBNB_TESTNET=

## Arbitrum
VITE_RPC_HTTP_URL_ARBITRUM_ONE=
VITE_SUBGRAPH_MARKETS_URL_ARBITRUM_ONE=
VITE_SUBGRAPH_GOVERNANCE_URL_ARBITRUM_ONE=

## Arbitrum Sepolia
VITE_RPC_HTTP_URL_ARBITRUM_SEPOLIA=
VITE_SUBGRAPH_MARKETS_URL_ARBITRUM_SEPOLIA=
VITE_SUBGRAPH_GOVERNANCE_URL_ARBITRUM_SEPOLIA=

## zkSync
VITE_RPC_HTTP_URL_ZKSYNC_MAINNET=
VITE_SUBGRAPH_MARKETS_URL_ZKSYNC_MAINNET=
VITE_SUBGRAPH_GOVERNANCE_URL_ZKSYNC_MAINNET=

## zkSync Sepolia
VITE_RPC_HTTP_URL_ZKSYNC_SEPOLIA=
VITE_SUBGRAPH_MARKETS_URL_ZKSYNC_SEPOLIA=
VITE_SUBGRAPH_GOVERNANCE_URL_ZKSYNC_SEPOLIA=

# Optimism mainnet
VITE_RPC_HTTP_URL_OPTIMISM_MAINNET=
VITE_SUBGRAPH_MARKETS_URL_OPTIMISM_MAINNET=
VITE_SUBGRAPH_GOVERNANCE_URL_OPTIMISM_MAINNET=

# Optimism Sepolia
VITE_RPC_HTTP_URL_OPTIMISM_SEPOLIA=
VITE_SUBGRAPH_MARKETS_URL_OPTIMISM_SEPOLIA=
VITE_SUBGRAPH_GOVERNANCE_URL_OPTIMISM_SEPOLIA=

# Error reporting

VITE_SENTRY_DSN=

# Analytics

VITE_POSTHOG_API_KEY=
VITE_POSTHOG_HOST_URL=

# ZyFi

# Zyfi
VITE_ZYFI_API_KEY=

# NodeReal
VITE_NODE_REAL_API_KEY=

# The Graph
VITE_THE_GRAPH_API_KEY=
50 changes: 50 additions & 0 deletions apps/evm/codegen.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/** @type {import('graphql-config').IGraphQLConfig } */

import { ChainId } from '@venusprotocol/chains/types';

import { getGovernanceSubgraphUrls, getIsolatedPoolsSubgraphUrls } from './src/config/subgraphUrls';

const keys = {
nodeRealApiKey: process.env.CODEGEN_UNRESTRICTED_NODE_REAL_API_KEY!,
theGraphApiKey: process.env.CODEGEN_UNRESTRICTED_THE_GRAPH_API_KEY!,
};

console.log(process.env);
console.log(
'CODEGEN_UNRESTRICTED_NODE_REAL_API_KEY',
process.env.CODEGEN_UNRESTRICTED_NODE_REAL_API_KEY,
);

const isolatedPoolsSubgraphUrls = getIsolatedPoolsSubgraphUrls(keys);
const governanceSubgraphUrls = getGovernanceSubgraphUrls(keys);

const plugins = ['typescript', 'typed-document-node', 'typescript-operations'];

export const projects = {
isolatedPools: {
schema: isolatedPoolsSubgraphUrls[ChainId.BSC_MAINNET],
documents: ['./src/clients/subgraph/queries/isolatedPools/**/*.graphql'],
extensions: {
codegen: {
generates: {
'./src/clients/subgraph/gql/generated/isolatedPools.ts': {
plugins,
},
},
},
},
},
governance: {
schema: governanceSubgraphUrls[ChainId.BSC_MAINNET],
documents: ['./src/clients/subgraph/queries/governance/**/*.graphql'],
extensions: {
codegen: {
generates: {
'./src/clients/subgraph/gql/generated/governance.ts': {
plugins,
},
},
},
},
},
};
11 changes: 7 additions & 4 deletions apps/evm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,17 @@
"lint:styles": "stylelint 'src/**/*.{css,scss,ts,tsx,js,jsx}'",
"tsc": "tsc --noEmit",
"extract-translations": "yarn i18next",
"generate-subgraph-types:isolated-pools": "yarn graphql-codegen --config src/config/codegen.ts --project isolatedPools",
"generate-subgraph-types:governance": "yarn graphql-codegen --config src/config/codegen.ts --project governance",
"generate-subgraph-types": "npm-run-all --parallel generate-subgraph-types:isolated-pools generate-subgraph-types:governance",
"generate-project-subgraph:project": "env > .env.generated.co && dotenvx run --env-file=.env.generated.co --env-file=.env -- yarn graphql-codegen --config codegen.config.ts --project $PROJECT && rm .env.generated.co",
"generate-subgraph-types:isolated-pools": "PROJECT=isolatedPools yarn generate-project-subgraph:project",
"generate-subgraph-types:governance": "PROJECT=governance yarn generate-project-subgraph:project",
"generate-subgraph-types": "yarn generate-subgraph-types:isolated-pools &&yarn generate-subgraph-types:governance",
"generate-contracts": "rimraf src/libs/contracts/generated/getters && rimraf src/libs/contracts/generated/infos && src/libs/contracts/scripts/generateContractRecords/index.ts && yarn biome format --vcs-use-ignore-file=false --write src/libs/contracts/generated",
"generate-pancake-swap-tokens": "src/libs/tokens/scripts/generatePancakeSwapTokenRecords/index.ts && yarn biome format --vcs-use-ignore-file=false --write src/libs/tokens/generated/pancakeSwapTokens/bscMainnet.ts",
"generate-version-files": "genversion --es6 --semi src/constants/version.ts && src/scripts/generatePublicVersionFile.ts && yarn biome format --vcs-use-ignore-file=false --write public/version.json",
"generate": "npm-run-all --parallel generate-version-files generate-contracts generate-subgraph-types && yarn generate-pancake-swap-tokens",
"storybook": "storybook dev -p 6006",
"storybook:build": "storybook build",
"postinstall": "yarn run generate"
"postinstall": "env && yarn run generate"
},
"dependencies": {
"@0xsequence/multicall": "^1.2.9",
Expand Down Expand Up @@ -84,6 +85,7 @@
"devDependencies": {
"@biomejs/biome": "1.6.4",
"@changesets/cli": "^2.27.1",
"@dotenvx/dotenvx": "^1.26.2",
"@ethersproject/abi": "^5.7.0",
"@ethersproject/abstract-provider": "^5.7.0",
"@graphql-codegen/add": "^5.0.0",
Expand Down Expand Up @@ -146,6 +148,7 @@
"storybook": "^8.4.2",
"stylelint": "^15.10.3",
"tailwindcss": "^3.3.3",
"tsconfig-paths": "^4.2.0",
"tsx": "^4.1.2",
"typechain": "^8.3.1",
"typescript": "^5.1.6",
Expand Down
4 changes: 2 additions & 2 deletions apps/evm/src/__mocks__/models/pools.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { chainMetadata } from '@venusprotocol/chains';
import BigNumber from 'bignumber.js';

import apiPoolsResponse from '__mocks__/api/pools.json';
import { assetData } from '__mocks__/models/asset';

import formatToPool from 'clients/api/queries/getApiPools/formatToPool';
import { CHAIN_METADATA } from 'constants/chainMetadata';
import { ChainId, type Pool } from 'types';

const { corePoolComptrollerContractAddress } = CHAIN_METADATA[ChainId.BSC_TESTNET];
const { corePoolComptrollerContractAddress } = chainMetadata[ChainId.BSC_TESTNET];

export const apiPoolsData = apiPoolsResponse.result.map(apiPoolData =>
formatToPool({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ export interface GetIsolatedPoolParticipantsCountInput {
export const getIsolatedPoolParticipantsCount = ({
chainId,
}: GetIsolatedPoolParticipantsCountInput) =>
config.marketsSubgraphUrls[chainId]
? request(config.marketsSubgraphUrls[chainId], IsolatedPoolParticipantsCountDocument)
config.isolatedPoolsSubgraphUrls[chainId]
? request(config.isolatedPoolsSubgraphUrls[chainId], IsolatedPoolParticipantsCountDocument)
: undefined;
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import type { Network } from 'types';

export const apiUrls: Record<Network, string> = {
export const apiUrls: {
[key in Network]: string;
} = {
testnet: 'https://testnetapi.venus.io',
mainnet: 'https://api.venus.io',
'mainnet-preview': 'https://api-preview.venus.io',
Expand Down
32 changes: 0 additions & 32 deletions apps/evm/src/config/codegen.ts

This file was deleted.

Loading

0 comments on commit 564731a

Please sign in to comment.