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 4, 2024
1 parent 7693a14 commit 3c8d00f
Show file tree
Hide file tree
Showing 37 changed files with 285 additions and 666 deletions.
5 changes: 5 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"
VITE_CODEGEN_UNRESTRICTED_NODE_REAL_API_KEY: ${{ secrets.VITE_CODEGEN_UNRESTRICTED_NODE_REAL_API_KEY }}
VITE_CODEGEN_UNRESTRICTED_THE_GRAPH_API_KEY: ${{ secrets.VITE_CODEGEN_UNRESTRICTED_THE_GRAPH_API_KEY }}

jobs:
release:
runs-on: ubuntu-latest
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"
VITE_CODEGEN_UNRESTRICTED_NODE_REAL_API_KEY: ${{ secrets.VITE_CODEGEN_UNRESTRICTED_NODE_REAL_API_KEY }}
VITE_CODEGEN_UNRESTRICTED_THE_GRAPH_API_KEY: ${{ secrets.VITE_CODEGEN_UNRESTRICTED_THE_GRAPH_API_KEY }}

jobs:
checks:
runs-on: ubuntu-22.04
Expand Down
80 changes: 11 additions & 69 deletions apps/evm/.env.template
Original file line number Diff line number Diff line change
@@ -1,81 +1,23 @@
# 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 One
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=
## Used at build-time only to generate subgraph types
VITE_CODEGEN_UNRESTRICTED_NODE_REAL_API_KEY=

# The Graph
VITE_THE_GRAPH_API_KEY=
## Used at build-time only to generate subgraph types
VITE_CODEGEN_UNRESTRICTED_THE_GRAPH_API_KEY=
60 changes: 60 additions & 0 deletions apps/evm/codegen.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/** @type {import('graphql-config').IGraphQLConfig } */

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

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

const keys = {
nodeRealApiKey: process.env.VITE_CODEGEN_UNRESTRICTED_NODE_REAL_API_KEY!,
theGraphApiKey: process.env.VITE_CODEGEN_UNRESTRICTED_THE_GRAPH_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'],
errorsOnly: true,
extensions: {
codegen: {
generates: {
'./src/clients/subgraph/gql/generated/isolatedPools.ts': {
plugins,
},
},
},
},
},
governanceBsc: {
schema: governanceSubgraphUrls[ChainId.BSC_MAINNET],
documents: ['./src/clients/subgraph/queries/governanceBsc/**/*.graphql'],
errorsOnly: true,
extensions: {
codegen: {
generates: {
'./src/clients/subgraph/gql/generated/governanceBsc.ts': {
plugins,
},
},
},
},
},
governanceNonBsc: {
schema: governanceSubgraphUrls[ChainId.ETHEREUM],
documents: ['./src/clients/subgraph/queries/governanceNonBsc/**/*.graphql'],
errorsOnly: true,
extensions: {
codegen: {
generates: {
'./src/clients/subgraph/gql/generated/governanceNonBsc.ts': {
plugins,
},
},
},
},
},
};
9 changes: 6 additions & 3 deletions apps/evm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@
"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-bsc": "yarn graphql-codegen --config src/config/codegen.ts --project governanceBsc",
"generate-subgraph-types:governance-non-bsc": "yarn graphql-codegen --config src/config/codegen.ts --project governanceNonBsc",
"generate-project-subgraph:project": "dotenvx run -f .env -- yarn graphql-codegen --config codegen.config.ts --project $PROJECT",
"generate-subgraph-types:isolated-pools": "PROJECT=isolatedPools yarn generate-project-subgraph:project",
"generate-subgraph-types:governance-bsc": "PROJECT=governanceBsc yarn generate-project-subgraph:project",
"generate-subgraph-types:governance-non-bsc": "PROJECT=governanceNonBsc yarn generate-project-subgraph:project",
"generate-subgraph-types": "yarn generate-subgraph-types:isolated-pools && yarn generate-subgraph-types:governance-bsc && yarn generate-subgraph-types:governance-non-bsc",
"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",
Expand Down Expand Up @@ -85,6 +86,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",
"@graphprotocol/client-cli": "^3.0.7",
Expand Down Expand Up @@ -148,6 +150,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
2 changes: 1 addition & 1 deletion apps/evm/src/clients/api/queries/getProposals/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
getBscProposals,
} from 'clients/subgraph';
import type { Proposal_Filter, RemoteProposal } from 'clients/subgraph/gql/generated/governanceBsc';
import { PROPOSAL_EXECUTION_GRACE_PERIOD_MS } from 'constants/chainMetadata';
import { PROPOSAL_EXECUTION_GRACE_PERIOD_MS } from 'constants/governance';
import { type ChainId, type Proposal, ProposalState } from 'types';

export interface GetProposalsInput {
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,4 +1,4 @@
import { PROPOSAL_EXECUTION_GRACE_PERIOD_MS } from 'constants/chainMetadata';
import { PROPOSAL_EXECUTION_GRACE_PERIOD_MS } from 'constants/governance';
import { ProposalState, RemoteProposalState } from 'types';
import { getRemoteProposalState } from '..';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PROPOSAL_EXECUTION_GRACE_PERIOD_MS } from 'constants/chainMetadata';
import { PROPOSAL_EXECUTION_GRACE_PERIOD_MS } from 'constants/governance';
import { ProposalState, RemoteProposalState } from 'types';

export const getRemoteProposalState = ({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { NonBscProposalFragment } from 'clients/subgraph/gql/generated/governanceNonBsc';
import { PROPOSAL_EXECUTION_GRACE_PERIOD_MS } from 'constants/chainMetadata';
import { PROPOSAL_EXECUTION_GRACE_PERIOD_MS } from 'constants/governance';
import { CHAIN_IDS_ON_LAYER_ZERO } from 'constants/layerZero';
import { ProposalState, type RemoteProposal, RemoteProposalState } from 'types';
import { convertToDate } from 'utilities';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { chainMetadata } from '@venusprotocol/chains';
import BigNumber from 'bignumber.js';

import type { BscProposalFragment } from 'clients/subgraph/gql/generated/governanceBsc';
import type { NonBscProposalFragment } from 'clients/subgraph/gql/generated/governanceNonBsc';
import { CHAIN_METADATA, PROPOSAL_EXECUTION_GRACE_PERIOD_MS } from 'constants/chainMetadata';
import { PROPOSAL_EXECUTION_GRACE_PERIOD_MS } from 'constants/governance';
import { governanceChain } from 'libs/wallet';
import {
type AbstainVoter,
Expand All @@ -24,7 +26,7 @@ import {
import { formatToProposalActions } from './formatToProposalActions';
import { formatToRemoteProposal } from './formatToRemoteProposal';

const { blockTimeMs: BSC_BLOCK_TIME_MS } = CHAIN_METADATA[governanceChain.id];
const { blockTimeMs: BSC_BLOCK_TIME_MS } = chainMetadata[governanceChain.id];

export const formatToProposal = ({
gqlProposal,
Expand Down
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
48 changes: 0 additions & 48 deletions apps/evm/src/config/codegen.ts

This file was deleted.

Loading

0 comments on commit 3c8d00f

Please sign in to comment.