From 8dab52d914ef5ae590cf0a3ba659758d48dc1b49 Mon Sep 17 00:00:00 2001 From: therealemjy Date: Wed, 27 Nov 2024 14:35:06 +0100 Subject: [PATCH] feat: remove RPC and subgraph URLs from chains package --- .github/workflows/cd.yaml | 8 + .github/workflows/ci.yaml | 10 +- .gitignore | 1 + apps/evm/.env.template | 76 +------- apps/evm/codegen.config.ts | 46 +++++ apps/evm/package.json | 11 +- apps/evm/src/__mocks__/models/pools.ts | 4 +- .../getIsolatedPoolParticipantsCount/index.ts | 4 +- .../{constants/api.ts => config/apiUrls.ts} | 4 +- apps/evm/src/config/codegen.ts | 32 ---- apps/evm/src/config/envVariables.ts | 178 +----------------- apps/evm/src/config/index.ts | 77 +++----- apps/evm/src/config/rpcUrls.ts | 21 +++ apps/evm/src/config/subgraphUrls.ts | 65 +++++++ apps/evm/vite.config.mts | 1 - package.json | 2 +- packages/chains/src/chainMetadata.ts | 55 +----- packages/chains/src/types.ts | 3 - yarn.lock | 102 +++++----- 19 files changed, 257 insertions(+), 443 deletions(-) create mode 100644 apps/evm/codegen.config.ts rename apps/evm/src/{constants/api.ts => config/apiUrls.ts} (74%) delete mode 100644 apps/evm/src/config/codegen.ts create mode 100644 apps/evm/src/config/rpcUrls.ts create mode 100644 apps/evm/src/config/subgraphUrls.ts diff --git a/.github/workflows/cd.yaml b/.github/workflows/cd.yaml index d4ed404e57..197562f277 100644 --- a/.github/workflows/cd.yaml +++ b/.github/workflows/cd.yaml @@ -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 @@ -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 diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 1adf2061cc..19b646073f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -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 diff --git a/.gitignore b/.gitignore index 8ff70045d8..2207fa2d2b 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ build out-tsc out generated +.env.generated.ci # Local environment variables .env diff --git a/apps/evm/.env.template b/apps/evm/.env.template index 98b8188d6c..7548b66f91 100644 --- a/apps/evm/.env.template +++ b/apps/evm/.env.template @@ -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= diff --git a/apps/evm/codegen.config.ts b/apps/evm/codegen.config.ts new file mode 100644 index 0000000000..b2bcf86b04 --- /dev/null +++ b/apps/evm/codegen.config.ts @@ -0,0 +1,46 @@ +/** @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); + +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, + }, + }, + }, + }, + }, +}; diff --git a/apps/evm/package.json b/apps/evm/package.json index f166cc0b36..cc86bdd757 100644 --- a/apps/evm/package.json +++ b/apps/evm/package.json @@ -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.ci && dotenvx run --env-file=.env.generated.ci -f .env -- yarn graphql-codegen --config codegen.config.ts --project $PROJECT && rm .env.generated.ci", + "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", @@ -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", @@ -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", diff --git a/apps/evm/src/__mocks__/models/pools.ts b/apps/evm/src/__mocks__/models/pools.ts index ddb106d6e6..0582978f71 100644 --- a/apps/evm/src/__mocks__/models/pools.ts +++ b/apps/evm/src/__mocks__/models/pools.ts @@ -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({ diff --git a/apps/evm/src/clients/subgraph/queries/isolatedPools/getIsolatedPoolParticipantsCount/index.ts b/apps/evm/src/clients/subgraph/queries/isolatedPools/getIsolatedPoolParticipantsCount/index.ts index e6d97fb972..b7fdf0db64 100644 --- a/apps/evm/src/clients/subgraph/queries/isolatedPools/getIsolatedPoolParticipantsCount/index.ts +++ b/apps/evm/src/clients/subgraph/queries/isolatedPools/getIsolatedPoolParticipantsCount/index.ts @@ -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; diff --git a/apps/evm/src/constants/api.ts b/apps/evm/src/config/apiUrls.ts similarity index 74% rename from apps/evm/src/constants/api.ts rename to apps/evm/src/config/apiUrls.ts index 31812ed61d..64e3f886a6 100644 --- a/apps/evm/src/constants/api.ts +++ b/apps/evm/src/config/apiUrls.ts @@ -1,6 +1,8 @@ import type { Network } from 'types'; -export const apiUrls: Record = { +export const apiUrls: { + [key in Network]: string; +} = { testnet: 'https://testnetapi.venus.io', mainnet: 'https://api.venus.io', 'mainnet-preview': 'https://api-preview.venus.io', diff --git a/apps/evm/src/config/codegen.ts b/apps/evm/src/config/codegen.ts deleted file mode 100644 index 90d1e0cc04..0000000000 --- a/apps/evm/src/config/codegen.ts +++ /dev/null @@ -1,32 +0,0 @@ -/** @type {import('graphql-config').IGraphQLConfig } */ - -const plugins = ['typescript', 'typed-document-node', 'typescript-operations']; - -export const projects = { - isolatedPools: { - schema: 'https://api.studio.thegraph.com/query/77761/venus-isolated-pools/version/latest', - documents: ['../clients/subgraph/queries/isolatedPools/**/*.graphql'], - extensions: { - codegen: { - generates: { - '../clients/subgraph/gql/generated/isolatedPools.ts': { - plugins, - }, - }, - }, - }, - }, - governance: { - schema: 'https://api.studio.thegraph.com/query/77761/venus-governance/version/latest', - documents: ['../clients/subgraph/queries/governance/**/*.graphql'], - extensions: { - codegen: { - generates: { - '../clients/subgraph/gql/generated/governance.ts': { - plugins, - }, - }, - }, - }, - }, -}; diff --git a/apps/evm/src/config/envVariables.ts b/apps/evm/src/config/envVariables.ts index a8cfb26145..1c509e3e95 100644 --- a/apps/evm/src/config/envVariables.ts +++ b/apps/evm/src/config/envVariables.ts @@ -1,178 +1,10 @@ // Note: because Vite statically replaces env variables when building, we need // to reference each of them by their full name -export const ENV_VARIABLES = { +export const envVariables = { VITE_ENV: typeof process !== 'undefined' ? process.env.VITE_ENV : import.meta.env.VITE_ENV, VITE_NETWORK: typeof process !== 'undefined' ? process.env.VITE_NETWORK : import.meta.env.VITE_NETWORK, - // BSC mainnet - VITE_RPC_HTTP_URL_BSC_MAINNET: - typeof process !== 'undefined' - ? process.env.VITE_RPC_HTTP_URL_BSC_MAINNET - : import.meta.env.VITE_RPC_HTTP_URL_BSC_MAINNET, - VITE_SUBGRAPH_MARKETS_URL_BSC_MAINNET: - typeof process !== 'undefined' - ? process.env.VITE_SUBGRAPH_MARKETS_URL_BSC_MAINNET - : import.meta.env.VITE_SUBGRAPH_MARKETS_URL_BSC_MAINNET, - VITE_SUBGRAPH_GOVERNANCE_URL_BSC_MAINNET: - typeof process !== 'undefined' - ? process.env.VITE_SUBGRAPH_GOVERNANCE_URL_BSC_MAINNET - : import.meta.env.VITE_SUBGRAPH_GOVERNANCE_URL_BSC_MAINNET, - - // BSC testnet - VITE_RPC_HTTP_URL_BSC_TESTNET: - typeof process !== 'undefined' - ? process.env.VITE_RPC_HTTP_URL_BSC_TESTNET - : import.meta.env.VITE_RPC_HTTP_URL_BSC_TESTNET, - VITE_SUBGRAPH_MARKETS_URL_BSC_TESTNET: - typeof process !== 'undefined' - ? process.env.VITE_SUBGRAPH_MARKETS_URL_BSC_TESTNET - : import.meta.env.VITE_SUBGRAPH_MARKETS_URL_BSC_TESTNET, - VITE_SUBGRAPH_GOVERNANCE_URL_BSC_TESTNET: - typeof process !== 'undefined' - ? process.env.VITE_SUBGRAPH_GOVERNANCE_URL_BSC_TESTNET - : import.meta.env.VITE_SUBGRAPH_GOVERNANCE_URL_BSC_TESTNET, - - // opBNB mainnet - VITE_RPC_HTTP_URL_OPBNB_MAINNET: - typeof process !== 'undefined' - ? process.env.VITE_RPC_HTTP_URL_OPBNB_MAINNET - : import.meta.env.VITE_RPC_HTTP_URL_OPBNB_MAINNET, - VITE_SUBGRAPH_MARKETS_URL_OPBNB_MAINNET: - typeof process !== 'undefined' - ? process.env.VITE_SUBGRAPH_MARKETS_URL_OPBNB_MAINNET - : import.meta.env.VITE_SUBGRAPH_MARKETS_URL_OPBNB_MAINNET, - VITE_SUBGRAPH_GOVERNANCE_URL_OPBNB_MAINNET: - typeof process !== 'undefined' - ? process.env.VITE_SUBGRAPH_GOVERNANCE_URL_OPBNB_MAINNET - : import.meta.env.VITE_SUBGRAPH_GOVERNANCE_URL_OPBNB_MAINNET, - - // opBNB testnet - VITE_RPC_HTTP_URL_OPBNB_TESTNET: - typeof process !== 'undefined' - ? process.env.VITE_RPC_HTTP_URL_OPBNB_TESTNET - : import.meta.env.VITE_RPC_HTTP_URL_OPBNB_TESTNET, - VITE_SUBGRAPH_MARKETS_URL_OPBNB_TESTNET: - typeof process !== 'undefined' - ? process.env.VITE_SUBGRAPH_MARKETS_URL_OPBNB_TESTNET - : import.meta.env.VITE_SUBGRAPH_MARKETS_URL_OPBNB_TESTNET, - VITE_SUBGRAPH_GOVERNANCE_URL_OPBNB_TESTNET: - typeof process !== 'undefined' - ? process.env.VITE_SUBGRAPH_GOVERNANCE_URL_OPBNB_TESTNET - : import.meta.env.VITE_SUBGRAPH_GOVERNANCE_URL_OPBNB_TESTNET, - - // Ethereum - VITE_RPC_HTTP_URL_ETHEREUM: - typeof process !== 'undefined' - ? process.env.VITE_RPC_HTTP_URL_ETHEREUM - : import.meta.env.VITE_RPC_HTTP_URL_ETHEREUM, - VITE_SUBGRAPH_MARKETS_URL_ETHEREUM: - typeof process !== 'undefined' - ? process.env.VITE_SUBGRAPH_MARKETS_URL_ETHEREUM - : import.meta.env.VITE_SUBGRAPH_MARKETS_URL_ETHEREUM, - VITE_SUBGRAPH_GOVERNANCE_URL_ETHEREUM: - typeof process !== 'undefined' - ? process.env.VITE_SUBGRAPH_GOVERNANCE_URL_ETHEREUM - : import.meta.env.VITE_SUBGRAPH_GOVERNANCE_URL_ETHEREUM, - - // Sepolia - VITE_RPC_HTTP_URL_SEPOLIA: - typeof process !== 'undefined' - ? process.env.VITE_RPC_HTTP_URL_SEPOLIA - : import.meta.env.VITE_RPC_HTTP_URL_SEPOLIA, - VITE_SUBGRAPH_MARKETS_URL_SEPOLIA: - typeof process !== 'undefined' - ? process.env.VITE_SUBGRAPH_MARKETS_URL_SEPOLIA - : import.meta.env.VITE_SUBGRAPH_MARKETS_URL_SEPOLIA, - VITE_SUBGRAPH_GOVERNANCE_URL_SEPOLIA: - typeof process !== 'undefined' - ? process.env.VITE_SUBGRAPH_GOVERNANCE_URL_SEPOLIA - : import.meta.env.VITE_SUBGRAPH_GOVERNANCE_URL_SEPOLIA, - - // Arbitrum - VITE_RPC_HTTP_URL_ARBITRUM_ONE: - typeof process !== 'undefined' - ? process.env.VITE_RPC_HTTP_URL_ARBITRUM_ONE - : import.meta.env.VITE_RPC_HTTP_URL_ARBITRUM_ONE, - VITE_SUBGRAPH_MARKETS_URL_ARBITRUM_ONE: - typeof process !== 'undefined' - ? process.env.VITE_SUBGRAPH_MARKETS_URL_ARBITRUM_ONE - : import.meta.env.VITE_SUBGRAPH_MARKETS_URL_ARBITRUM_ONE, - VITE_SUBGRAPH_GOVERNANCE_URL_ARBITRUM_ONE: - typeof process !== 'undefined' - ? process.env.VITE_SUBGRAPH_GOVERNANCE_URL_ARBITRUM_ONE - : import.meta.env.VITE_SUBGRAPH_GOVERNANCE_URL_ARBITRUM_ONE, - - // Arbitrum Sepolia - VITE_RPC_HTTP_URL_ARBITRUM_SEPOLIA: - typeof process !== 'undefined' - ? process.env.VITE_RPC_HTTP_URL_ARBITRUM_SEPOLIA - : import.meta.env.VITE_RPC_HTTP_URL_ARBITRUM_SEPOLIA, - VITE_SUBGRAPH_MARKETS_URL_ARBITRUM_SEPOLIA: - typeof process !== 'undefined' - ? process.env.VITE_SUBGRAPH_MARKETS_URL_ARBITRUM_SEPOLIA - : import.meta.env.VITE_SUBGRAPH_MARKETS_URL_ARBITRUM_SEPOLIA, - VITE_SUBGRAPH_GOVERNANCE_URL_ARBITRUM_SEPOLIA: - typeof process !== 'undefined' - ? process.env.VITE_SUBGRAPH_GOVERNANCE_URL_ARBITRUM_SEPOLIA - : import.meta.env.VITE_SUBGRAPH_GOVERNANCE_URL_ARBITRUM_SEPOLIA, - - // zkSync Sepolia - VITE_RPC_HTTP_URL_ZKSYNC_SEPOLIA: - typeof process !== 'undefined' - ? process.env.VITE_RPC_HTTP_URL_ZKSYNC_SEPOLIA - : import.meta.env.VITE_RPC_HTTP_URL_ZKSYNC_SEPOLIA, - VITE_SUBGRAPH_MARKETS_URL_ZKSYNC_SEPOLIA: - typeof process !== 'undefined' - ? process.env.VITE_SUBGRAPH_MARKETS_URL_ZKSYNC_SEPOLIA - : import.meta.env.VITE_SUBGRAPH_MARKETS_URL_ZKSYNC_SEPOLIA, - VITE_SUBGRAPH_GOVERNANCE_URL_ZKSYNC_SEPOLIA: - typeof process !== 'undefined' - ? process.env.VITE_SUBGRAPH_GOVERNANCE_URL_ZKSYNC_SEPOLIA - : import.meta.env.VITE_SUBGRAPH_GOVERNANCE_URL_ZKSYNC_SEPOLIA, - - // zkSync mainnet - VITE_RPC_HTTP_URL_ZKSYNC_MAINNET: - typeof process !== 'undefined' - ? process.env.VITE_RPC_HTTP_URL_ZKSYNC_MAINNET - : import.meta.env.VITE_RPC_HTTP_URL_ZKSYNC_MAINNET, - VITE_SUBGRAPH_MARKETS_URL_ZKSYNC_MAINNET: - typeof process !== 'undefined' - ? process.env.VITE_SUBGRAPH_MARKETS_URL_ZKSYNC_MAINNET - : import.meta.env.VITE_SUBGRAPH_MARKETS_URL_ZKSYNC_MAINNET, - VITE_SUBGRAPH_GOVERNANCE_URL_ZKSYNC_MAINNET: - typeof process !== 'undefined' - ? process.env.VITE_SUBGRAPH_GOVERNANCE_URL_ZKSYNC_MAINNET - : import.meta.env.VITE_SUBGRAPH_GOVERNANCE_URL_ZKSYNC_MAINNET, - - // Optimism mainnet - VITE_RPC_HTTP_URL_OPTIMISM_MAINNET: - typeof process !== 'undefined' - ? process.env.VITE_RPC_HTTP_URL_OPTIMISM_MAINNET - : import.meta.env.VITE_RPC_HTTP_URL_OPTIMISM_MAINNET, - VITE_SUBGRAPH_MARKETS_URL_OPTIMISM_MAINNET: - typeof process !== 'undefined' - ? process.env.VITE_SUBGRAPH_MARKETS_URL_OPTIMISM_MAINNET - : import.meta.env.VITE_SUBGRAPH_MARKETS_URL_OPTIMISM_MAINNET, - VITE_SUBGRAPH_GOVERNANCE_URL_OPTIMISM_MAINNET: - typeof process !== 'undefined' - ? process.env.VITE_SUBGRAPH_GOVERNANCE_URL_OPTIMISM_MAINNET - : import.meta.env.VITE_SUBGRAPH_GOVERNANCE_URL_OPTIMISM_MAINNET, - - // Optimism Sepolia - VITE_RPC_HTTP_URL_OPTIMISM_SEPOLIA: - typeof process !== 'undefined' - ? process.env.VITE_RPC_HTTP_URL_OPTIMISM_SEPOLIA - : import.meta.env.VITE_RPC_HTTP_URL_OPTIMISM_SEPOLIA, - VITE_SUBGRAPH_MARKETS_URL_OPTIMISM_SEPOLIA: - typeof process !== 'undefined' - ? process.env.VITE_SUBGRAPH_MARKETS_URL_OPTIMISM_SEPOLIA - : import.meta.env.VITE_SUBGRAPH_MARKETS_URL_OPTIMISM_SEPOLIA, - VITE_SUBGRAPH_GOVERNANCE_URL_OPTIMISM_SEPOLIA: - typeof process !== 'undefined' - ? process.env.VITE_SUBGRAPH_GOVERNANCE_URL_OPTIMISM_SEPOLIA - : import.meta.env.VITE_SUBGRAPH_GOVERNANCE_URL_OPTIMISM_SEPOLIA, - // Third-parties VITE_SENTRY_DSN: typeof process !== 'undefined' ? process.env.VITE_SENTRY_DSN : import.meta.env.VITE_SENTRY_DSN, @@ -188,4 +20,12 @@ export const ENV_VARIABLES = { typeof process !== 'undefined' ? process.env.VITE_ZYFI_API_KEY : import.meta.env.VITE_ZYFI_API_KEY, + VITE_NODE_REAL_API_KEY: + typeof process !== 'undefined' + ? process.env.VITE_NODE_REAL_API_KEY + : import.meta.env.VITE_NODE_REAL_API_KEY, + VITE_THE_GRAPH_API_KEY: + typeof process !== 'undefined' + ? process.env.VITE_THE_GRAPH_API_KEY + : import.meta.env.VITE_THE_GRAPH_API_KEY, }; diff --git a/apps/evm/src/config/index.ts b/apps/evm/src/config/index.ts index 760ccee79e..11496e3c84 100644 --- a/apps/evm/src/config/index.ts +++ b/apps/evm/src/config/index.ts @@ -1,9 +1,9 @@ -import { chainMetadata } from '@venusprotocol/chains'; -import { apiUrls } from 'constants/api'; -import { ChainId, type Environment, type Network } from 'types'; -import { extractEnumValues } from 'utilities/extractEnumValues'; +import type { ChainId, Environment, Network } from 'types'; -import { ENV_VARIABLES } from './envVariables'; +import { apiUrls } from './apiUrls'; +import { envVariables } from './envVariables'; +import { rpcUrls } from './rpcUrls'; +import { getGovernanceSubgraphUrls, getIsolatedPoolsSubgraphUrls } from './subgraphUrls'; export interface Config { environment: Environment; @@ -12,11 +12,11 @@ export interface Config { rpcUrls: { [chainId in ChainId]: string; }; - marketsSubgraphUrls: { - [chainId in ChainId]: string; + isolatedPoolsSubgraphUrls: { + [chainId in ChainId]: string | undefined; }; governanceSubgraphUrls: { - [chainId in ChainId]: string; + [chainId in ChainId]: string | undefined; }; sentryDsn: string; posthog: { @@ -26,64 +26,33 @@ export interface Config { zyFiApiKey: string; } -const environment: Environment = ENV_VARIABLES.VITE_ENV || 'preview'; -const network: Network = ENV_VARIABLES.VITE_NETWORK || 'mainnet'; +const environment: Environment = envVariables.VITE_ENV || 'preview'; +const network: Network = envVariables.VITE_NETWORK || 'mainnet'; -const chainIds = extractEnumValues(ChainId); - -const { rpcUrls, marketsSubgraphUrls, governanceSubgraphUrls } = chainIds.reduce( - (acc, chainId) => { - const chainKey = ChainId[chainId]; - const chain = chainMetadata[chainId]; +const apiUrl = apiUrls[network]; - return { - rpcUrls: { - ...acc.rpcUrls, - [chainId]: - ENV_VARIABLES[`VITE_RPC_HTTP_URL_${chainKey}` as keyof typeof ENV_VARIABLES] || - chain.rpcUrl, - }, - marketsSubgraphUrls: { - ...acc.marketsSubgraphUrls, - [chainId]: - ENV_VARIABLES[`VITE_SUBGRAPH_MARKETS_URL_${chainKey}` as keyof typeof ENV_VARIABLES] || - chain.marketsSubgraphUrl, - }, - governanceSubgraphUrls: { - ...acc.governanceSubgraphUrls, - [chainId]: - ENV_VARIABLES[`VITE_SUBGRAPH_GOVERNANCE_URL_${chainKey}` as keyof typeof ENV_VARIABLES] || - chain.governanceSubgraphUrl, - }, - }; - }, - { - rpcUrls: {}, - marketsSubgraphUrls: {}, - governanceSubgraphUrls: {}, - } as { - rpcUrls: Record; - marketsSubgraphUrls: Record; - governanceSubgraphUrls: Record; - }, -); +const keys = { + nodeRealApiKey: envVariables.VITE_NODE_REAL_API_KEY, + theGraphApiKey: envVariables.VITE_THE_GRAPH_API_KEY, +}; -const apiUrl = apiUrls[network]; +const governanceSubgraphUrls = getGovernanceSubgraphUrls(keys); +const isolatedPoolsSubgraphUrls = getIsolatedPoolsSubgraphUrls(keys); const config: Config = { environment, network, apiUrl, rpcUrls, - marketsSubgraphUrls, + isolatedPoolsSubgraphUrls, governanceSubgraphUrls, - sentryDsn: ENV_VARIABLES.VITE_SENTRY_DSN || '', + sentryDsn: envVariables.VITE_SENTRY_DSN || '', posthog: { - apiKey: ENV_VARIABLES.VITE_POSTHOG_API_KEY || '', - hostUrl: ENV_VARIABLES.VITE_POSTHOG_HOST_URL || '', + apiKey: envVariables.VITE_POSTHOG_API_KEY || '', + hostUrl: envVariables.VITE_POSTHOG_HOST_URL || '', }, - zyFiApiKey: ENV_VARIABLES.VITE_ZYFI_API_KEY || '', + zyFiApiKey: envVariables.VITE_ZYFI_API_KEY || '', }; -export { ENV_VARIABLES } from './envVariables'; +export { envVariables } from './envVariables'; export default config; diff --git a/apps/evm/src/config/rpcUrls.ts b/apps/evm/src/config/rpcUrls.ts new file mode 100644 index 0000000000..e3afb7c74d --- /dev/null +++ b/apps/evm/src/config/rpcUrls.ts @@ -0,0 +1,21 @@ +import { ChainId } from '@venusprotocol/chains/types'; + +import { envVariables } from './envVariables'; + +export const rpcUrls: { + [chainId in ChainId]: string; +} = { + [ChainId.BSC_MAINNET]: `https://bsc-mainnet.nodereal.io/v1/${envVariables.VITE_NODE_REAL_API_KEY}`, + [ChainId.BSC_TESTNET]: `https://bsc-testnet.nodereal.io/v1/${envVariables.VITE_NODE_REAL_API_KEY}`, + [ChainId.OPBNB_MAINNET]: `https://opbnb-mainnet.nodereal.io/v1/${envVariables.VITE_NODE_REAL_API_KEY}`, + [ChainId.OPBNB_TESTNET]: `https://opbnb-testnet.nodereal.io/v1/${envVariables.VITE_NODE_REAL_API_KEY}`, + [ChainId.ETHEREUM]: `https://eth-mainnet.nodereal.io/v1/${envVariables.VITE_NODE_REAL_API_KEY}`, + [ChainId.SEPOLIA]: `https://eth-sepolia.nodereal.io/v1/${envVariables.VITE_NODE_REAL_API_KEY}`, + [ChainId.ARBITRUM_ONE]: `https://open-platform.nodereal.io/${envVariables.VITE_NODE_REAL_API_KEY}/arbitrum-nitro`, + [ChainId.ARBITRUM_SEPOLIA]: + 'https://rpc.ankr.com/arbitrum_sepolia/451c00a15d3de617618d7a880cec1da8065b10906c460b1462a8b8769d91e0da', + [ChainId.ZKSYNC_MAINNET]: `https://open-platform.nodereal.io/${envVariables.VITE_NODE_REAL_API_KEY}/zksync`, + [ChainId.ZKSYNC_SEPOLIA]: 'https://sepolia.era.zksync.dev', + [ChainId.OPTIMISM_MAINNET]: `https://opt-mainnet.nodereal.io/v1/${envVariables.VITE_NODE_REAL_API_KEY}`, + [ChainId.OPTIMISM_SEPOLIA]: 'https://sepolia.optimism.io', +}; diff --git a/apps/evm/src/config/subgraphUrls.ts b/apps/evm/src/config/subgraphUrls.ts new file mode 100644 index 0000000000..37d93fb90d --- /dev/null +++ b/apps/evm/src/config/subgraphUrls.ts @@ -0,0 +1,65 @@ +import { ChainId } from '@venusprotocol/chains/types'; + +export const getIsolatedPoolsSubgraphUrls = ({ + nodeRealApiKey, + theGraphApiKey, +}: { + nodeRealApiKey: string; + theGraphApiKey: string; +}) => { + const subgraphUrls: { + [chainId in ChainId]: string | undefined; + } = { + [ChainId.BSC_MAINNET]: `https://gateway-arbitrum.network.thegraph.com/api/${theGraphApiKey}/deployments/id/QmVMKvBgAgnqVrLmRUurMiziH3Q55Fa5VoYJXN4TVLZgsw`, + [ChainId.BSC_TESTNET]: + 'https://api.studio.thegraph.com/query/77761/venus-isolated-pools-chapel/version/latest', + [ChainId.OPBNB_MAINNET]: `https://open-platform-ap.nodereal.io/${nodeRealApiKey}/opbnb-mainnet-graph-query/subgraphs/name/venusprotocol/venus-isolated-pools-opbnb`, + [ChainId.OPBNB_TESTNET]: undefined, + [ChainId.ETHEREUM]: `https://gateway-arbitrum.network.thegraph.com/api/${theGraphApiKey}/deployments/id/Qmazi4kSKzahgR5G6U7FVUoUGLQZQVPohRX6zbuxbC8YX1`, + [ChainId.SEPOLIA]: + 'https://api.studio.thegraph.com/query/64786/venus-isolated-pools-sepolia/version/latest', + [ChainId.ARBITRUM_ONE]: `https://gateway-arbitrum.network.thegraph.com/api/${theGraphApiKey}/deployments/id/QmQByQzsGpuVqaZcfraxQduUwMX4JpnAnFd1s1JTkSUREj`, + [ChainId.ARBITRUM_SEPOLIA]: + 'https://api.studio.thegraph.com/query/64786/venus-il-arbitrumsepolia/version/latest', + [ChainId.ZKSYNC_MAINNET]: `https://gateway.thegraph.com/api/${theGraphApiKey}/deployments/id/Qma87oPwwDfvsmBySPJQLsFKc8JXBQaJvS12MYGGku2bRG`, + [ChainId.ZKSYNC_SEPOLIA]: + 'https://api.studio.thegraph.com/query/64786/venus-il-zksync-sepolia/version/latest', + [ChainId.OPTIMISM_MAINNET]: `https://gateway.thegraph.com/api/${theGraphApiKey}/deployments/id/QmZqvM6BRz1nNvK41SbfcafW2sbLZpnDMmubpQ5phkmPD8`, + [ChainId.OPTIMISM_SEPOLIA]: + 'https://api.studio.thegraph.com/query/64786/venus-il-optimism-sepolia/version/latest', + }; + + return subgraphUrls; +}; + +export const getGovernanceSubgraphUrls = ({ + nodeRealApiKey, + theGraphApiKey, +}: { + nodeRealApiKey: string; + theGraphApiKey: string; +}) => { + const subgraphUrls: { + [chainId in ChainId]: string | undefined; + } = { + [ChainId.BSC_MAINNET]: `https://gateway-arbitrum.network.thegraph.com/api/${theGraphApiKey}/deployments/id/QmVAi2T8BptC9hjfJG8oYBT5xQQZR4x6Fnr8WjyRivkbaD`, + [ChainId.BSC_TESTNET]: + 'https://api.studio.thegraph.com/query/64786/venus-governance-chapel/version/latest', + [ChainId.OPBNB_MAINNET]: `https://open-platform-ap.nodereal.io/${nodeRealApiKey}/opbnb-mainnet-graph-query/subgraphs/name/venusprotocol/venus-governance-opbnb`, + [ChainId.OPBNB_TESTNET]: undefined, + [ChainId.ETHEREUM]: `https://gateway.thegraph.com/api/${theGraphApiKey}/deployments/id/QmUXMrtcyqXtzgHVQ8VAtsUJMKuDr7gk9WhHUgertioVZY`, + [ChainId.SEPOLIA]: + 'https://api.studio.thegraph.com/query/64786/venus-governance-sepolia/version/latest', + [ChainId.ARBITRUM_ONE]: `https://gateway.thegraph.com/api/${theGraphApiKey}/deployments/id/QmfUtsb2bQvFnPhxTNYemvQB3qqKvm27rZRFwm2X6yajyh`, + [ChainId.ARBITRUM_SEPOLIA]: + 'https://api.studio.thegraph.com/query/64786/venus-governance-arbisepolia/version/latest', + [ChainId.ZKSYNC_MAINNET]: `https://gateway.thegraph.com/api/${theGraphApiKey}/deployments/id/QmcdLyjbM4bLv8TEHuCcBgWrJc1nh4b6mhKSZnz2DMGAhU`, + [ChainId.ZKSYNC_SEPOLIA]: + 'https://api.studio.thegraph.com/query/64786/venus-governance-zksyncsepolia/version/latest', + [ChainId.OPTIMISM_MAINNET]: `https://gateway.thegraph.com/api/${theGraphApiKey}/deployments/id/QmdTVnzZrFhVn3Q158b3E2rNPFPmEEfyQwgN3im2GbCQLy`, + [ChainId.OPTIMISM_SEPOLIA]: + 'https://api.studio.thegraph.com/query/64786/venus-governance-opsepolia/version/latest', + }; + + return subgraphUrls; +}; diff --git a/apps/evm/vite.config.mts b/apps/evm/vite.config.mts index 4a7e205292..fe87e3c4fa 100644 --- a/apps/evm/vite.config.mts +++ b/apps/evm/vite.config.mts @@ -59,7 +59,6 @@ export default defineConfig(({ mode }) => { '**/*/types.ts', 'src/setupTests.tsx', 'src/stories/', - 'src/config/codegen.ts', 'src/libs/contracts/generated', ], }, diff --git a/package.json b/package.json index 86b48e941f..cdb16f6b81 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "extract-translations": "turbo extract-translations", "changeset": "changeset", "changeset:version": "changeset version", - "postinstall": "husky && yarn run generate" + "postinstall": "husky && env && yarn run generate" }, "devDependencies": { "@changesets/cli": "^2.27.1", diff --git a/packages/chains/src/chainMetadata.ts b/packages/chains/src/chainMetadata.ts index 7571d12e00..c33c0a9fd9 100644 --- a/packages/chains/src/chainMetadata.ts +++ b/packages/chains/src/chainMetadata.ts @@ -40,11 +40,6 @@ export const chainMetadata: { corePoolComptrollerContractAddress: '0xfD36E2c2a6789Db23113685031d7F16329158384', proposalExecutionGracePeriodMs: PROPOSAL_EXECUTION_GRACE_PERIOD_MS, nativeToken: bnbToken, - rpcUrl: 'https://bsc-mainnet.nodereal.io/v1/7fab7575d1c34150a9ee582167ffac6f', - marketsSubgraphUrl: - 'https://gateway-arbitrum.network.thegraph.com/api/43fa98f50f96a8e1b63423e8ead8c6dc/deployments/id/QmVMKvBgAgnqVrLmRUurMiziH3Q55Fa5VoYJXN4TVLZgsw', - governanceSubgraphUrl: - 'https://gateway-arbitrum.network.thegraph.com/api/43fa98f50f96a8e1b63423e8ead8c6dc/deployments/id/QmVAi2T8BptC9hjfJG8oYBT5xQQZR4x6Fnr8WjyRivkbaD', }, [ChainId.BSC_TESTNET]: { name: 'BNB testnet', @@ -56,11 +51,6 @@ export const chainMetadata: { corePoolComptrollerContractAddress: '0x94d1820b2D1c7c7452A163983Dc888CEC546b77D', proposalExecutionGracePeriodMs: PROPOSAL_EXECUTION_GRACE_PERIOD_MS, nativeToken: bnbToken, - rpcUrl: 'https://bsc-testnet.nodereal.io/v1/7fab7575d1c34150a9ee582167ffac6f', - marketsSubgraphUrl: - 'https://api.studio.thegraph.com/query/77761/venus-isolated-pools-chapel/version/latest', - governanceSubgraphUrl: - 'https://api.studio.thegraph.com/query/64786/venus-governance-chapel/version/latest', }, [ChainId.OPBNB_MAINNET]: { name: 'opBNB', @@ -71,9 +61,6 @@ export const chainMetadata: { blocksPerDay: 86400, corePoolComptrollerContractAddress: '0xD6e3E2A1d8d95caE355D15b3b9f8E5c2511874dd', nativeToken: bnbToken, - rpcUrl: 'https://opbnb-mainnet.nodereal.io/v1/7fab7575d1c34150a9ee582167ffac6f', - marketsSubgraphUrl: - 'https://open-platform-ap.nodereal.io/7fab7575d1c34150a9ee582167ffac6f/opbnb-mainnet-graph-query/subgraphs/name/venusprotocol/venus-isolated-pools-opbnb', }, [ChainId.OPBNB_TESTNET]: { name: 'opBNB testnet', @@ -84,7 +71,6 @@ export const chainMetadata: { blocksPerDay: 86400, corePoolComptrollerContractAddress: '0x2FCABb31E57F010D623D8d68e1E18Aed11d5A388', nativeToken: bnbToken, - rpcUrl: 'https://opbnb-testnet.nodereal.io/v1/7fab7575d1c34150a9ee582167ffac6f', }, [ChainId.ETHEREUM]: { name: 'Ethereum', @@ -97,9 +83,6 @@ export const chainMetadata: { lstPoolComptrollerContractAddress: '0xF522cd0360EF8c2FF48B648d53EA1717Ec0F3Ac3', lstPoolVWstEthContractAddress: '0x4a240F0ee138697726C8a3E43eFE6Ac3593432CB', nativeToken: ethToken, - rpcUrl: 'https://eth-mainnet.nodereal.io/v1/7fab7575d1c34150a9ee582167ffac6f', - marketsSubgraphUrl: - 'https://gateway-arbitrum.network.thegraph.com/api/43fa98f50f96a8e1b63423e8ead8c6dc/deployments/id/Qmazi4kSKzahgR5G6U7FVUoUGLQZQVPohRX6zbuxbC8YX1', }, [ChainId.SEPOLIA]: { name: 'Sepolia', @@ -112,9 +95,6 @@ export const chainMetadata: { lstPoolComptrollerContractAddress: '0xd79CeB8EF8188E44b7Eb899094e8A3A4d7A1e236', lstPoolVWstEthContractAddress: '0x0a95088403229331FeF1EB26a11F9d6C8E73f23D', nativeToken: ethToken, - rpcUrl: 'https://eth-sepolia.nodereal.io/v1/7fab7575d1c34150a9ee582167ffac6f', - marketsSubgraphUrl: - 'https://api.studio.thegraph.com/query/64786/venus-isolated-pools-sepolia/version/latest', }, [ChainId.ARBITRUM_ONE]: { name: 'Arbitrum One', @@ -125,9 +105,6 @@ export const chainMetadata: { lstPoolComptrollerContractAddress: '0x52bAB1aF7Ff770551BD05b9FC2329a0Bf5E23F16', lstPoolVWstEthContractAddress: '0x9df6B5132135f14719696bBAe3C54BAb272fDb16', nativeToken: ethToken, - rpcUrl: 'https://open-platform.nodereal.io/7fab7575d1c34150a9ee582167ffac6f/arbitrum-nitro', - marketsSubgraphUrl: - 'https://gateway-arbitrum.network.thegraph.com/api/43fa98f50f96a8e1b63423e8ead8c6dc/deployments/id/QmQByQzsGpuVqaZcfraxQduUwMX4JpnAnFd1s1JTkSUREj', }, [ChainId.ARBITRUM_SEPOLIA]: { name: 'Arbitrum Sepolia', @@ -138,21 +115,6 @@ export const chainMetadata: { lstPoolComptrollerContractAddress: '0x3D04F926b2a165BBa17FBfccCCB61513634fa5e4', lstPoolVWstEthContractAddress: '0x253515E19e8b888a4CA5a0a3363B712402ce4046', nativeToken: ethToken, - rpcUrl: - 'https://rpc.ankr.com/arbitrum_sepolia/451c00a15d3de617618d7a880cec1da8065b10906c460b1462a8b8769d91e0da', - marketsSubgraphUrl: - 'https://api.studio.thegraph.com/query/64786/venus-il-arbitrumsepolia/version/latest', - }, - [ChainId.ZKSYNC_SEPOLIA]: { - name: 'zkSync Sepolia', - logoSrc: zkSyncLogo, - explorerUrl: 'https://sepolia.explorer.zksync.io', - layerZeroScanUrl: 'https://testnet.layerzeroscan.com', - corePoolComptrollerContractAddress: '0xC527DE08E43aeFD759F7c0e6aE85433923064669', - nativeToken: ethToken, - rpcUrl: 'https://sepolia.era.zksync.dev', - marketsSubgraphUrl: - 'https://api.studio.thegraph.com/query/64786/venus-il-zksync-sepolia/version/latest', }, [ChainId.ZKSYNC_MAINNET]: { name: 'zkSync', @@ -161,9 +123,14 @@ export const chainMetadata: { layerZeroScanUrl: 'https://layerzeroscan.com', corePoolComptrollerContractAddress: '0xddE4D098D9995B659724ae6d5E3FB9681Ac941B1', nativeToken: ethToken, - rpcUrl: 'https://open-platform.nodereal.io/7fab7575d1c34150a9ee582167ffac6f/zksync', - marketsSubgraphUrl: - 'https://gateway.thegraph.com/api/43fa98f50f96a8e1b63423e8ead8c6dc/deployments/id/Qma87oPwwDfvsmBySPJQLsFKc8JXBQaJvS12MYGGku2bRG', + }, + [ChainId.ZKSYNC_SEPOLIA]: { + name: 'zkSync Sepolia', + logoSrc: zkSyncLogo, + explorerUrl: 'https://sepolia.explorer.zksync.io', + layerZeroScanUrl: 'https://testnet.layerzeroscan.com', + corePoolComptrollerContractAddress: '0xC527DE08E43aeFD759F7c0e6aE85433923064669', + nativeToken: ethToken, }, [ChainId.OPTIMISM_MAINNET]: { name: 'Optimism', @@ -172,9 +139,6 @@ export const chainMetadata: { layerZeroScanUrl: 'https://layerzeroscan.com', corePoolComptrollerContractAddress: '0x5593FF68bE84C966821eEf5F0a988C285D5B7CeC', nativeToken: ethToken, - rpcUrl: 'https://opt-mainnet.nodereal.io/v1/7fab7575d1c34150a9ee582167ffac6f', - marketsSubgraphUrl: - 'https://gateway.thegraph.com/api/43fa98f50f96a8e1b63423e8ead8c6dc/deployments/id/QmZqvM6BRz1nNvK41SbfcafW2sbLZpnDMmubpQ5phkmPD8', }, [ChainId.OPTIMISM_SEPOLIA]: { name: 'Optimism Sepolia', @@ -183,8 +147,5 @@ export const chainMetadata: { layerZeroScanUrl: 'https://testnet.layerzeroscan.com', corePoolComptrollerContractAddress: '0x59d10988974223B042767aaBFb6D926863069535', nativeToken: ethToken, - rpcUrl: 'https://sepolia.optimism.io', - marketsSubgraphUrl: - 'https://gateway.testnet.thegraph.com/api/43fa98f50f96a8e1b63423e8ead8c6dc/deployments/id/QmNcLHq8xaDMhqqUFGAnafauXp4S3LAU8xAicnBMoYaB9i', }, }; diff --git a/packages/chains/src/types.ts b/packages/chains/src/types.ts index a237f85ddf..fde6c4e69a 100644 --- a/packages/chains/src/types.ts +++ b/packages/chains/src/types.ts @@ -38,9 +38,6 @@ export interface ChainMetadata { nativeToken: Token; layerZeroScanUrl: string; corePoolComptrollerContractAddress: string; - rpcUrl: string; - marketsSubgraphUrl?: string; - governanceSubgraphUrl?: string; lstPoolVWstEthContractAddress?: string; lstPoolComptrollerContractAddress?: string; proposalExecutionGracePeriodMs?: number; diff --git a/yarn.lock b/yarn.lock index 7a773bc048..c29f1ed09d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1326,6 +1326,21 @@ rxjs "^7.2.0" semver "^7.3.5" +"@dotenvx/dotenvx@^1.26.2": + version "1.26.2" + resolved "https://registry.yarnpkg.com/@dotenvx/dotenvx/-/dotenvx-1.26.2.tgz#4fbb11405e59f8fdae379b5138644d1d1856712c" + integrity sha512-s0yu7OBQLDKL3nrpR6SBj3G76b/3Qho4gkyWItqcVK9xyCJtme4g9p7NF5cMhO1BGSPSYZgpXQR6c6JgyNiwKA== + dependencies: + commander "^11.1.0" + dotenv "^16.4.5" + eciesjs "^0.4.10" + execa "^5.1.1" + fdir "^6.2.0" + ignore "^5.3.0" + object-treeify "1.1.33" + picomatch "^4.0.2" + which "^4.0.0" + "@ecies/ciphers@^0.2.1": version "0.2.2" resolved "https://registry.yarnpkg.com/@ecies/ciphers/-/ciphers-0.2.2.tgz#82a15b10a6e502b63fb30915d944b2eaf3ff17ff" @@ -1430,7 +1445,7 @@ resolved "https://registry.yarnpkg.com/@emotion/sheet/-/sheet-1.4.0.tgz#c9299c34d248bc26e82563735f78953d2efca83c" integrity sha512-fTBW9/8r2w3dXWYM4HCB1Rdp8NLibOw2+XELH5m5+AkWiL/KqYX6dc0kKYlaYyKjrQ6ds33MCdMPEwgs2z1rqg== -"@emotion/styled@^11.0.0", "@emotion/styled@^11.11.0": +"@emotion/styled@^11.11.0": version "11.13.5" resolved "https://registry.yarnpkg.com/@emotion/styled/-/styled-11.13.5.tgz#0fa6602227414c5e42cf267506e3c35bae655df9" integrity sha512-gnOQ+nGLPvDXgIx119JqGalys64lhMdnNQA9TMxhDA4K0Hq5+++OE20Zs5GxiCV9r814xQ2K5WmtofSpHVW6BQ== @@ -3861,7 +3876,7 @@ resolved "https://registry.yarnpkg.com/@oozcitak/util/-/util-8.3.8.tgz#10f65fe1891fd8cde4957360835e78fd1936bfdd" integrity sha512-T8TbSnGsxo6TDBJx/Sgv/BlVJL3tshxZP7Aq5R1mSnM5OcHY2dQaxLMu2+E8u3gN0MLOzdjurqN4ZRVuzQycOQ== -"@openzeppelin-3/contracts@npm:@openzeppelin/contracts@^3.4.2-solc-0.7": +"@openzeppelin-3/contracts@npm:@openzeppelin/contracts@^3.4.2-solc-0.7", "@openzeppelin/contracts-v0.7@npm:@openzeppelin/contracts@v3.4.2": version "3.4.2" resolved "https://registry.yarnpkg.com/@openzeppelin/contracts/-/contracts-3.4.2.tgz#d81f786fda2871d1eb8a8c5a73e455753ba53527" integrity sha512-z0zMCjyhhp4y7XKAcDAi3Vgms4T2PstwBdahiO0+9NaGICQKjynK3wduSRplTgk4LXmoO1yfDGO5RbjKYxtuxA== @@ -3876,11 +3891,6 @@ resolved "https://registry.yarnpkg.com/@openzeppelin/contracts-upgradeable/-/contracts-upgradeable-4.9.5.tgz#572b5da102fc9be1d73f34968e0ca56765969812" integrity sha512-f7L1//4sLlflAN7fVzJLoRedrf5Na3Oal5PZfIq55NFcVZ90EpV1q5xOvL4lFvg3MNICSDr2hH0JUBxwlxcoPg== -"@openzeppelin/contracts-v0.7@npm:@openzeppelin/contracts@v3.4.2": - version "3.4.2" - resolved "https://registry.yarnpkg.com/@openzeppelin/contracts/-/contracts-3.4.2.tgz#d81f786fda2871d1eb8a8c5a73e455753ba53527" - integrity sha512-z0zMCjyhhp4y7XKAcDAi3Vgms4T2PstwBdahiO0+9NaGICQKjynK3wduSRplTgk4LXmoO1yfDGO5RbjKYxtuxA== - "@openzeppelin/contracts@3.4.2-solc-0.7": version "3.4.2-solc-0.7" resolved "https://registry.yarnpkg.com/@openzeppelin/contracts/-/contracts-3.4.2-solc-0.7.tgz#38f4dbab672631034076ccdf2f3201fab1726635" @@ -7548,14 +7558,6 @@ chokidar@^4.0.0: dependencies: readdirp "^4.0.1" -chrome-remote-interface@^0.32.1: - version "0.32.2" - resolved "https://registry.yarnpkg.com/chrome-remote-interface/-/chrome-remote-interface-0.32.2.tgz#4c494b9d074997b45d49137232df48a355189278" - integrity sha512-3UbFKtEmqApehPQnqdblcggx7KveQphEMKQmdJZsOguE9ylw2N2/9Z7arO7xS55+DBJ/hyP8RrayLt4MMdJvQg== - dependencies: - commander "2.11.x" - ws "^7.2.0" - ci-info@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-2.0.0.tgz#67a9e964be31a51e15e5010d58e6f12834002f46" @@ -7805,16 +7807,16 @@ command-line-usage@^6.1.0: table-layout "^1.0.2" typical "^5.2.0" -commander@2.11.x: - version "2.11.0" - resolved "https://registry.yarnpkg.com/commander/-/commander-2.11.0.tgz#157152fd1e7a6c8d98a5b715cf376df928004563" - integrity sha512-b0553uYA5YAEGgyYIGYROzKQ7X5RAqedkfjiZxwi0kL1g3bOaBNNZfYkzt/CL0umgD5wc9Jec2FbB98CjkMRvQ== - commander@3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/commander/-/commander-3.0.2.tgz#6837c3fb677ad9933d1cfba42dd14d5117d6b39e" integrity sha512-Gar0ASD4BDyKC4hl4DwHqDrmvjoxWKZigVnAbn5H1owvm4CxCPdb0HQDehwNYMJpla5+M2tPmPARzhtYuwpHow== +commander@^11.1.0: + version "11.1.0" + resolved "https://registry.yarnpkg.com/commander/-/commander-11.1.0.tgz#62fdce76006a68e5c1ab3314dc92e800eb83d906" + integrity sha512-yPVavfyCcRhmorC7rWlkHn15b4wDVgVmBA7kV4QVBsF7kv/9TKJAbAXVTxvTnwP8HHKjRCJDClKbciiYS7p0DQ== + commander@^4.0.0: version "4.1.1" resolved "https://registry.yarnpkg.com/commander/-/commander-4.1.1.tgz#9fd602bd936294e9e9ef46a3f4d6964044b18068" @@ -8612,6 +8614,11 @@ dotenv@^16.0.0, dotenv@^16.0.1, dotenv@^16.3.1: resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-16.3.1.tgz#369034de7d7e5b120972693352a3bf112172cc3e" integrity sha512-IPzF4w4/Rd94bA9imS68tZBaYyBWSCE47V1RGuMrB94iyTOIEwRmVL2x/4An+6mETpLrKJ5hQkB8W4kFAadeIQ== +dotenv@^16.4.5: + version "16.4.6" + resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-16.4.6.tgz#fc88e8a664087abf3e19d61e21f7feee1849bbb1" + integrity sha512-JhcR/+KIjkkjiU8yEpaB/USlzVi3i5whwOjpIRNGi9svKEXZSe+Qp6IWAjFjv+2GViAoDRCUv/QLNziQxsLqDg== + dset@^3.1.2: version "3.1.4" resolved "https://registry.yarnpkg.com/dset/-/dset-3.1.4.tgz#f8eaf5f023f068a036d08cd07dc9ffb7d0065248" @@ -8632,7 +8639,7 @@ eastasianwidth@^0.2.0: resolved "https://registry.yarnpkg.com/eastasianwidth/-/eastasianwidth-0.2.0.tgz#696ce2ec0aa0e6ea93a397ffcf24aa7840c827cb" integrity sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA== -eciesjs@^0.4.11: +eciesjs@^0.4.10, eciesjs@^0.4.11: version "0.4.12" resolved "https://registry.yarnpkg.com/eciesjs/-/eciesjs-0.4.12.tgz#0ce482454953592e07b79b4824751f3b5c508b56" integrity sha512-DGejvMCihsRAmKRFQiL6KZDE34vWVd0gvXlykFq1aEzJy/rD65AVyAIUZKZOvgvaP9ATQRcHGEZV5DfgrgjA4w== @@ -9395,6 +9402,11 @@ fbjs@^3.0.0: setimmediate "^1.0.5" ua-parser-js "^0.7.30" +fdir@^6.2.0: + version "6.4.2" + resolved "https://registry.yarnpkg.com/fdir/-/fdir-6.4.2.tgz#ddaa7ce1831b161bc3657bb99cb36e1622702689" + integrity sha512-KnhMXsKSPZlAhp7+IjUkRZKPb4fUyccpDrdFXbi4QL1qkmFh9kVY09Yox+n4MaOb3lHZ1Tv829C3oaaXoMYPDQ== + fetch-blob@^3.1.2, fetch-blob@^3.1.4: version "3.2.0" resolved "https://registry.yarnpkg.com/fetch-blob/-/fetch-blob-3.2.0.tgz#f09b8d4bbd45adc6f0c20b7e787e793e309dcce9" @@ -12921,6 +12933,11 @@ object-keys@^1.1.1: resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.1.1.tgz#1c47f272df277f3b1daf061677d9c82e2322c60e" integrity sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA== +object-treeify@1.1.33: + version "1.1.33" + resolved "https://registry.yarnpkg.com/object-treeify/-/object-treeify-1.1.33.tgz#f06fece986830a3cba78ddd32d4c11d1f76cdf40" + integrity sha512-EFVjAYfzWqWsBMRHPMAXLCDIJnpMhdWAqR7xG6M6a2cs6PMFpl/+Z20w9zDW4vkxOFfddegBKq9Rehd0bxWE7A== + object.assign@^4.1.4: version "4.1.4" resolved "https://registry.yarnpkg.com/object.assign/-/object.assign-4.1.4.tgz#9673c7c7c351ab8c4d0b516f4343ebf4dfb7799f" @@ -15260,7 +15277,7 @@ string-format@^2.0.0: resolved "https://registry.yarnpkg.com/string-format/-/string-format-2.0.0.tgz#f2df2e7097440d3b65de31b6d40d54c96eaffb9b" integrity sha512-bbEs3scLeYNXLecRRuk6uJxdXUSj6le/8rNPHChIJTn2V79aXVTR1EH2OH5zLKKoz0V02fOUKZZcw01pLUShZA== -"string-width-cjs@npm:string-width@^4.2.0": +"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.0.0, string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.2, string-width@^4.2.3: version "4.2.3" resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== @@ -15277,15 +15294,6 @@ string-width@^2.1.1: is-fullwidth-code-point "^2.0.0" strip-ansi "^4.0.0" -string-width@^4.0.0, string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.2, string-width@^4.2.3: - version "4.2.3" - resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" - integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== - dependencies: - emoji-regex "^8.0.0" - is-fullwidth-code-point "^3.0.0" - strip-ansi "^6.0.1" - string-width@^5.0.1, string-width@^5.1.2: version "5.1.2" resolved "https://registry.yarnpkg.com/string-width/-/string-width-5.1.2.tgz#14f8daec6d81e7221d2a357e668cab73bdbca794" @@ -15336,7 +15344,7 @@ string_decoder@~1.1.1: dependencies: safe-buffer "~5.1.0" -"strip-ansi-cjs@npm:strip-ansi@^6.0.1": +"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1: version "6.0.1" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== @@ -15350,13 +15358,6 @@ strip-ansi@^4.0.0: dependencies: ansi-regex "^3.0.0" -strip-ansi@^6.0.0, strip-ansi@^6.0.1: - version "6.0.1" - resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" - integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== - dependencies: - ansi-regex "^5.0.1" - strip-ansi@^7.0.1, strip-ansi@^7.1.0: version "7.1.0" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-7.1.0.tgz#d5b6568ca689d8561370b0707685d22434faff45" @@ -16972,6 +16973,13 @@ which@^2.0.1, which@^2.0.2: dependencies: isexe "^2.0.0" +which@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/which/-/which-4.0.0.tgz#cd60b5e74503a3fbcfbf6cd6b4138a8bae644c1a" + integrity sha512-GlaYyEb07DPxYCKhKzplCWBJtvxZcZMrL+4UkrTSJHHPyZU4mYYTv3qaOe77H7EODLSSopAUFAc6W8U4yqvscg== + dependencies: + isexe "^3.1.1" + which@^5.0.0: version "5.0.0" resolved "https://registry.yarnpkg.com/which/-/which-5.0.0.tgz#d93f2d93f79834d4363c7d0c23e00d07c466c8d6" @@ -17012,7 +17020,7 @@ workerpool@6.2.1: resolved "https://registry.yarnpkg.com/workerpool/-/workerpool-6.2.1.tgz#46fc150c17d826b86a008e5a4508656777e9c343" integrity sha512-ILEIE97kDZvF9Wb9f6h5aXK4swSlKGUcOEGiIYb2OOu/IrDU9iwj0fD//SsA6E5ibwJxpEvhullJY4Sl4GcpAw== -"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0": +"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0: version "7.0.0" resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== @@ -17030,15 +17038,6 @@ wrap-ansi@^6.0.1, wrap-ansi@^6.2.0: string-width "^4.1.0" strip-ansi "^6.0.0" -wrap-ansi@^7.0.0: - version "7.0.0" - resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" - integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== - dependencies: - ansi-styles "^4.0.0" - string-width "^4.1.0" - strip-ansi "^6.0.0" - wrap-ansi@^8.1.0: version "8.1.0" resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214" @@ -17076,11 +17075,6 @@ ws@8.18.0, ws@^8.12.0, ws@^8.18.0, ws@^8.2.3: resolved "https://registry.yarnpkg.com/ws/-/ws-8.18.0.tgz#0d7505a6eafe2b0e712d232b42279f53bc289bbc" integrity sha512-8VbfWfHLbbwu3+N6OKsOMpBdT4kXPDDB9cJk2bJ6mh9ucxdlnNvH1e+roYkKmN9Nxw2yjz7VzeO9oOz2zJ04Pw== -ws@^7.2.0: - version "7.5.10" - resolved "https://registry.yarnpkg.com/ws/-/ws-7.5.10.tgz#58b5c20dc281633f6c19113f39b349bd8bd558d9" - integrity sha512-+dbF1tHwZpXcbOJdVOkzLDxZP1ailvSxM6ZweXTegylPny803bFhA+vqBYw4s31NSAk4S2Qz+AKXK9a4wkdjcQ== - ws@^7.4.6, ws@^7.5.1: version "7.5.9" resolved "https://registry.yarnpkg.com/ws/-/ws-7.5.9.tgz#54fa7db29f4c7cec68b1ddd3a89de099942bb591"