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 d8f6382
Show file tree
Hide file tree
Showing 18 changed files with 226 additions and 388 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
12 changes: 8 additions & 4 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@ 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"
VITE_CODEGEN_UNRESTRICTED_NODE_REAL_API_KEY: ${{ secrets.CODEGEN_UNRESTRICTED_NODE_REAL_API_KEY }}
CODEGEN_UNRESTRICTED_NODE_REAL_API_KEY: ${{ secrets.CODEGEN_UNRESTRICTED_NODE_REAL_API_KEY }}
VITE_CODEGEN_UNRESTRICTED_THE_GRAPH_API_KEY: ${{ secrets.CODEGEN_UNRESTRICTED_THE_GRAPH_API_KEY }}
CODEGEN_UNRESTRICTED_THE_GRAPH_API_KEY: ${{ secrets.CODEGEN_UNRESTRICTED_THE_GRAPH_API_KEY }}

jobs:
checks:
runs-on: ubuntu-22.04
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=
53 changes: 53 additions & 0 deletions apps/evm/codegen.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/** @type {import('graphql-config').IGraphQLConfig } */

import dotenv from 'dotenv';
dotenv.config();

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);
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,
},
},
},
},
},
};
8 changes: 5 additions & 3 deletions apps/evm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@
"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:isolated-pools": "yarn graphql-codegen --config codegen.config.ts --project isolatedPools",
"generate-subgraph-types:governance": "yarn graphql-codegen --config codegen.config.ts --project governance",
"generate-subgraph-types": "npm-run-all --parallel generate-subgraph-types:isolated-pools 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 @@ -126,6 +126,7 @@
"@vitest/coverage-v8": "^2.1.5",
"autoprefixer": "^10.4.16",
"c8": "^10.0.0",
"dotenv": "^16.4.5",
"fs": "^0.0.1-security",
"genversion": "^3.1.1",
"handlebars": "^4.7.8",
Expand All @@ -146,6 +147,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 d8f6382

Please sign in to comment.