From 3c8d00fe6babee53649747242c9e7a005c14d808 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 | 5 + .github/workflows/ci.yaml | 10 +- apps/evm/.env.template | 80 ++------ apps/evm/codegen.config.ts | 60 ++++++ apps/evm/package.json | 9 +- apps/evm/src/__mocks__/models/pools.ts | 4 +- .../clients/api/queries/getProposals/index.ts | 2 +- .../getIsolatedPoolParticipantsCount/index.ts | 4 +- .../__tests__/index.spec.ts | 2 +- .../getRemoteProposalState/index.ts | 2 +- .../formatToRemoteProposal/index.ts | 2 +- .../utilities/formatToProposal/index.ts | 6 +- .../{constants/api.ts => config/apiUrls.ts} | 4 +- apps/evm/src/config/codegen.ts | 48 ----- apps/evm/src/config/envVariables.ts | 178 +----------------- apps/evm/src/config/index.ts | 73 +++---- apps/evm/src/config/rpcUrls.ts | 21 +++ apps/evm/src/config/subgraphUrls.ts | 65 +++++++ apps/evm/src/constants/governance.ts | 1 + .../src/containers/ConnectWallet/index.tsx | 14 +- apps/evm/src/pages/Account/Settings/index.tsx | 4 +- .../Proposal/Commands/BscCommand/index.tsx | 4 +- .../Proposal/Commands/Command/Cta/index.tsx | 86 --------- .../pages/Proposal/Commands/Command/index.tsx | 2 +- .../Proposal/Commands/NonBscCommand/index.tsx | 18 +- .../__snapshots__/index.spec.tsx.snap | 15 -- .../Commands/__tests__/index.spec.tsx | 71 ------- ...> index.omnichainGovernance.spec.tsx.snap} | 0 .../index.omnichainGovernance.tsx.snap | 35 ---- ...tsx => index.omnichainGovernance.spec.tsx} | 0 apps/evm/src/utilities/generateExplorerUrl.ts | 4 +- .../getProposalState/__tests__/index.spec.ts | 2 +- .../src/utilities/getProposalState/index.ts | 2 +- apps/evm/vite.config.mts | 1 - packages/chains/src/chainMetadata.ts | 77 +------- packages/chains/src/types.ts | 3 - yarn.lock | 37 +++- 37 files changed, 285 insertions(+), 666 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 create mode 100644 apps/evm/src/constants/governance.ts delete mode 100644 apps/evm/src/pages/Proposal/Commands/Command/Cta/index.tsx delete mode 100644 apps/evm/src/pages/Proposal/Commands/__tests__/__snapshots__/index.spec.tsx.snap delete mode 100644 apps/evm/src/pages/Proposal/Commands/__tests__/index.spec.tsx rename apps/evm/src/pages/Proposal/__tests__/__snapshots__/{index. omnichainGovernance.spec.tsx.snap => index.omnichainGovernance.spec.tsx.snap} (100%) delete mode 100644 apps/evm/src/pages/Proposal/__tests__/__snapshots__/index.omnichainGovernance.tsx.snap rename apps/evm/src/pages/Proposal/__tests__/{index. omnichainGovernance.spec.tsx => index.omnichainGovernance.spec.tsx} (100%) diff --git a/.github/workflows/cd.yaml b/.github/workflows/cd.yaml index d4ed404e57..d24946d03c 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" + 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 diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 1adf2061cc..d5a5e58371 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" + 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 diff --git a/apps/evm/.env.template b/apps/evm/.env.template index 1ece123916..f6042473b5 100644 --- a/apps/evm/.env.template +++ b/apps/evm/.env.template @@ -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= diff --git a/apps/evm/codegen.config.ts b/apps/evm/codegen.config.ts new file mode 100644 index 0000000000..b2c42aa90d --- /dev/null +++ b/apps/evm/codegen.config.ts @@ -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, + }, + }, + }, + }, + }, +}; diff --git a/apps/evm/package.json b/apps/evm/package.json index 46fa08a4ac..1c475543e9 100644 --- a/apps/evm/package.json +++ b/apps/evm/package.json @@ -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", @@ -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", @@ -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", 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/api/queries/getProposals/index.ts b/apps/evm/src/clients/api/queries/getProposals/index.ts index 960baaf266..aee131152f 100644 --- a/apps/evm/src/clients/api/queries/getProposals/index.ts +++ b/apps/evm/src/clients/api/queries/getProposals/index.ts @@ -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 { 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 2513caf2bb..3e397730f1 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/clients/subgraph/utilities/formatToProposal/formatToRemoteProposal/getRemoteProposalState/__tests__/index.spec.ts b/apps/evm/src/clients/subgraph/utilities/formatToProposal/formatToRemoteProposal/getRemoteProposalState/__tests__/index.spec.ts index a66c5dff59..b54dda4ce9 100644 --- a/apps/evm/src/clients/subgraph/utilities/formatToProposal/formatToRemoteProposal/getRemoteProposalState/__tests__/index.spec.ts +++ b/apps/evm/src/clients/subgraph/utilities/formatToProposal/formatToRemoteProposal/getRemoteProposalState/__tests__/index.spec.ts @@ -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 '..'; diff --git a/apps/evm/src/clients/subgraph/utilities/formatToProposal/formatToRemoteProposal/getRemoteProposalState/index.ts b/apps/evm/src/clients/subgraph/utilities/formatToProposal/formatToRemoteProposal/getRemoteProposalState/index.ts index 62bc23e6ac..ee7f82204c 100644 --- a/apps/evm/src/clients/subgraph/utilities/formatToProposal/formatToRemoteProposal/getRemoteProposalState/index.ts +++ b/apps/evm/src/clients/subgraph/utilities/formatToProposal/formatToRemoteProposal/getRemoteProposalState/index.ts @@ -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 = ({ diff --git a/apps/evm/src/clients/subgraph/utilities/formatToProposal/formatToRemoteProposal/index.ts b/apps/evm/src/clients/subgraph/utilities/formatToProposal/formatToRemoteProposal/index.ts index 125a43b5a7..d2b025b4cb 100644 --- a/apps/evm/src/clients/subgraph/utilities/formatToProposal/formatToRemoteProposal/index.ts +++ b/apps/evm/src/clients/subgraph/utilities/formatToProposal/formatToRemoteProposal/index.ts @@ -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'; diff --git a/apps/evm/src/clients/subgraph/utilities/formatToProposal/index.ts b/apps/evm/src/clients/subgraph/utilities/formatToProposal/index.ts index 64ff123f8a..815b182acf 100644 --- a/apps/evm/src/clients/subgraph/utilities/formatToProposal/index.ts +++ b/apps/evm/src/clients/subgraph/utilities/formatToProposal/index.ts @@ -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, @@ -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, 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 f85e7ae271..0000000000 --- a/apps/evm/src/config/codegen.ts +++ /dev/null @@ -1,48 +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'], - errorsOnly: true, - extensions: { - codegen: { - generates: { - '../clients/subgraph/gql/generated/isolatedPools.ts': { - plugins, - }, - }, - }, - }, - }, - governanceBsc: { - schema: 'https://api.studio.thegraph.com/query/77761/venus-governance/version/latest', - documents: ['../clients/subgraph/queries/governanceBsc/**/*.graphql'], - errorsOnly: true, - extensions: { - codegen: { - generates: { - '../clients/subgraph/gql/generated/governanceBsc.ts': { - plugins, - }, - }, - }, - }, - }, - governanceNonBsc: { - schema: 'https://api.studio.thegraph.com/query/77761/venus-governance-ethereum/version/latest', - documents: ['../clients/subgraph/queries/governanceNonBsc/**/*.graphql'], - errorsOnly: true, - extensions: { - codegen: { - generates: { - '../clients/subgraph/gql/generated/governanceNonBsc.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 23d1e9116f..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,7 +12,7 @@ export interface Config { rpcUrls: { [chainId in ChainId]: string; }; - marketsSubgraphUrls: { + isolatedPoolsSubgraphUrls: { [chainId in ChainId]: string | undefined; }; governanceSubgraphUrls: { @@ -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..25d37ed5e1 --- /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/QmRCMZJjxi3oKCtbh5CY4gBT2E21Cbz65DAzmnKMNPNGLV`, + [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/src/constants/governance.ts b/apps/evm/src/constants/governance.ts new file mode 100644 index 0000000000..27fab7f3df --- /dev/null +++ b/apps/evm/src/constants/governance.ts @@ -0,0 +1 @@ +export const PROPOSAL_EXECUTION_GRACE_PERIOD_MS = 14 * 24 * 60 * 60 * 1000; // 14 days in milliseconds diff --git a/apps/evm/src/containers/ConnectWallet/index.tsx b/apps/evm/src/containers/ConnectWallet/index.tsx index c86d02e87d..62f94d25bd 100644 --- a/apps/evm/src/containers/ConnectWallet/index.tsx +++ b/apps/evm/src/containers/ConnectWallet/index.tsx @@ -1,11 +1,11 @@ +import { chainMetadata } from '@venusprotocol/chains'; +import { useMemo } from 'react'; + +import { Button, type Variant } from 'components/Button'; +import { NoticeInfo } from 'components/Notice'; import { useTranslation } from 'libs/translations'; import { useAccountAddress, useAuthModal, useChainId, useSwitchChain } from 'libs/wallet'; - -import { CHAIN_METADATA } from 'constants/chainMetadata'; -import { useMemo } from 'react'; import type { ChainId } from 'types'; -import { Button, type Variant } from '../../components/Button'; -import { NoticeInfo } from '../../components/Notice'; import { Container } from './Container'; export interface ConnectWalletProps extends React.HTMLAttributes { @@ -33,7 +33,7 @@ export const ConnectWallet: React.FC = ({ [currentChainId, chainId], ); - const chainMetadata = chainId && CHAIN_METADATA[chainId]; + const chain = chainId && chainMetadata[chainId]; const { openAuthModal } = useAuthModal(); const { switchChain } = useSwitchChain(); @@ -58,7 +58,7 @@ export const ConnectWallet: React.FC = ({ diff --git a/apps/evm/src/pages/Account/Settings/index.tsx b/apps/evm/src/pages/Account/Settings/index.tsx index 9cabd9b6a9..d671e24e2b 100644 --- a/apps/evm/src/pages/Account/Settings/index.tsx +++ b/apps/evm/src/pages/Account/Settings/index.tsx @@ -7,7 +7,7 @@ import Section from '../Section'; export const Settings: React.FC = () => { const { t } = useTranslation(); - const chainMetadata = useGetChainMetadata(); + const { name: chainName } = useGetChainMetadata(); const isGaslessTransactionsFeatureEnabled = useIsFeatureEnabled({ name: 'gaslessTransactions' }); const [{ gaslessTransactions }, setUserChainSettings] = useUserChainSettings(); @@ -31,7 +31,7 @@ export const Settings: React.FC = () => {

{t('account.settings.gaslessTransactions.switchLabel', { - chainName: chainMetadata.name, + chainName, })}

diff --git a/apps/evm/src/pages/Proposal/Commands/BscCommand/index.tsx b/apps/evm/src/pages/Proposal/Commands/BscCommand/index.tsx index 29371034df..bd608b2e23 100644 --- a/apps/evm/src/pages/Proposal/Commands/BscCommand/index.tsx +++ b/apps/evm/src/pages/Proposal/Commands/BscCommand/index.tsx @@ -1,4 +1,4 @@ -import { CHAIN_METADATA } from 'constants/chainMetadata'; +import { chainMetadata } from '@venusprotocol/chains'; import { useTranslation } from 'libs/translations'; import { governanceChain, useChainId } from 'libs/wallet'; import { useAccountAddress } from 'libs/wallet'; @@ -11,7 +11,7 @@ import { useIsProposalExecutable } from '../useIsProposalExecutable'; import { ActionButton } from './ActionButton'; import { CurrentStep } from './CurrentStep'; -const governanceChainMetadata = CHAIN_METADATA[governanceChain.id]; +const governanceChainMetadata = chainMetadata[governanceChain.id]; export interface BscCommandProps extends React.HTMLAttributes { proposal: Proposal; diff --git a/apps/evm/src/pages/Proposal/Commands/Command/Cta/index.tsx b/apps/evm/src/pages/Proposal/Commands/Command/Cta/index.tsx deleted file mode 100644 index 127858ad5b..0000000000 --- a/apps/evm/src/pages/Proposal/Commands/Command/Cta/index.tsx +++ /dev/null @@ -1,86 +0,0 @@ -import { chainMetadata } from '@venusprotocol/chains'; -import { Button } from 'components'; -import { useTranslation } from 'libs/translations'; -import { useSwitchChain } from 'libs/wallet'; -import { useMemo } from 'react'; -import type { ProposalCommand } from 'types'; -import { useCommand } from '../useCommand'; - -export type CtaProps = Omit, 'onClick'> & - Pick< - ProposalCommand, - | 'chainId' - | 'state' - | 'failedExecutionAt' - | 'canceledAt' - | 'bridgedAt' - | 'queuedAt' - | 'succeededAt' - | 'executableAt' - | 'executedAt' - | 'expiredAt' - >; - -export const Cta: React.FC = ({ - chainId, - state, - failedExecutionAt, - canceledAt, - bridgedAt, - queuedAt, - executableAt, - executedAt, - expiredAt, - ...otherProps -}) => { - const { t } = useTranslation(); - const chain = chainMetadata[chainId]; - - const { isOnWrongChain, hasFailedExecution } = useCommand({ - chainId, - state, - executableAt, - failedExecutionAt, - executedAt, - }); - - const { switchChain } = useSwitchChain(); - - // TODO: wire up (see VEN-2701) - const execute = () => {}; - const retry = () => {}; - - const onClick = (e: React.MouseEvent) => { - e.stopPropagation(); - - if (isOnWrongChain) { - return switchChain({ chainId }); - } - - if (hasFailedExecution) { - return retry(); - } - - return execute(); - }; - - const buttonLabel = useMemo(() => { - if (isOnWrongChain) { - return t('voteProposalUi.command.cta.wrongChain', { - chainName: chain.name, - }); - } - - if (hasFailedExecution) { - return t('voteProposalUi.command.cta.retry'); - } - - return t('voteProposalUi.command.cta.execute'); - }, [t, isOnWrongChain, hasFailedExecution, chain.name]); - - return ( - - ); -}; diff --git a/apps/evm/src/pages/Proposal/Commands/Command/index.tsx b/apps/evm/src/pages/Proposal/Commands/Command/index.tsx index 7ec2749895..c3abcafcb4 100644 --- a/apps/evm/src/pages/Proposal/Commands/Command/index.tsx +++ b/apps/evm/src/pages/Proposal/Commands/Command/index.tsx @@ -23,7 +23,7 @@ export const Command: React.FC = ({ contentBottomItem, ...otherProps }) => { - const { chain } = chainMetadata[chainId]; + const chain = chainMetadata[chainId]; const [isOpen, setIsOpen] = useState(false); const toggleAccordion = () => setIsOpen(prevState => !prevState); diff --git a/apps/evm/src/pages/Proposal/Commands/NonBscCommand/index.tsx b/apps/evm/src/pages/Proposal/Commands/NonBscCommand/index.tsx index 09235f93e2..9de0abb686 100644 --- a/apps/evm/src/pages/Proposal/Commands/NonBscCommand/index.tsx +++ b/apps/evm/src/pages/Proposal/Commands/NonBscCommand/index.tsx @@ -1,6 +1,6 @@ +import { chainMetadata } from '@venusprotocol/chains'; import { useExecuteProposal } from 'clients/api'; import { Button } from 'components'; -import { CHAIN_METADATA } from 'constants/chainMetadata'; import { ConnectWallet } from 'containers/ConnectWallet'; import { isAfter } from 'date-fns/isAfter'; import { useNow } from 'hooks/useNow'; @@ -14,7 +14,7 @@ import { Description } from '../Description'; import { useIsProposalExecutable } from '../useIsProposalExecutable'; import { CurrentStep } from './CurrentStep'; -const governanceChainMetadata = CHAIN_METADATA[governanceChain.id]; +const governanceChainMetadata = chainMetadata[governanceChain.id]; export interface NonBscCommand extends React.HTMLAttributes { remoteProposal: RemoteProposal; @@ -30,8 +30,7 @@ export const NonBscCommand: React.FC = ({ const now = useNow(); const { chainId: currentChainId } = useChainId(); - const chainMetadata = CHAIN_METADATA[remoteProposal.chainId]; - + const chain = chainMetadata[remoteProposal.chainId]; const isOnWrongChain = currentChainId !== remoteProposal.chainId; const { isExecutable } = useIsProposalExecutable({ @@ -74,19 +73,12 @@ export const NonBscCommand: React.FC = ({ if (isOnWrongChain) { return t('voteProposalUi.command.description.wrongChain', { - chainName: chainMetadata.name, + chainName: chain.name, }); } break; } - }, [ - t, - remoteProposal.state, - remoteProposal.executionEtaDate, - now, - chainMetadata, - isOnWrongChain, - ]); + }, [t, remoteProposal.state, remoteProposal.executionEtaDate, now, chain, isOnWrongChain]); return ( displays the right information for each command 1`] = `"BNB testnetExecuted01 Feb 2023 12:00 AM"`; - -exports[`Commands > displays the right information for each command 2`] = `"opBNB testnetWaiting for the bridge to propagate the transactionBridged01 Feb 2023 12:00 AMQueued on 01 Feb 2023 12:00 AM"`; - -exports[`Commands > displays the right information for each command 3`] = `"SepoliaWaiting for queueing period to endQueued01 Feb 2023 12:00 AMExecutable on 01 Feb 2089 12:00 AM"`; - -exports[`Commands > displays the right information for each command 4`] = `"SepoliaThis payload needs to be executed on the Sepolia chainSwitch to SepoliaSwitch to Sepolia"`; - -exports[`Commands > displays the right information for each command 5`] = `"Arbitrum SepoliaPayload execution cancelled by governance guardianCanceled01 Feb 2023 00:00 AM"`; - -exports[`Commands > displays the right information for each command 6`] = `"Arbitrum SepoliaPayload execution cancelled by governance guardianCanceled01 Feb 2023 12:00 AM"`; - -exports[`Commands > displays the right information for each command 7`] = `"Arbitrum SepoliaExecuted01 Feb 2023 12:00 AM"`; diff --git a/apps/evm/src/pages/Proposal/Commands/__tests__/index.spec.tsx b/apps/evm/src/pages/Proposal/Commands/__tests__/index.spec.tsx deleted file mode 100644 index 2baa08592e..0000000000 --- a/apps/evm/src/pages/Proposal/Commands/__tests__/index.spec.tsx +++ /dev/null @@ -1,71 +0,0 @@ -import { fireEvent, screen, waitFor } from '@testing-library/react'; -import { chainMetadata } from '@venusprotocol/chains'; -import { commands as fakeCommands } from '__mocks__/models/proposalCommands'; -import { en } from 'libs/translations'; -import { useSwitchChain } from 'libs/wallet'; -import { renderComponent } from 'testUtils/render'; -import type Vi from 'vitest'; -import { Commands } from '..'; -import TEST_IDS from '../../testIds'; - -describe('Commands', () => { - it('renders without crashing', () => { - renderComponent(); - }); - - it('displays the correct count of executed payloads', () => { - renderComponent(); - - const executedCommandsCount = fakeCommands.filter(command => !!command.executedAt).length; - expect(screen.getByText(`${executedCommandsCount}/${fakeCommands.length}`)).toBeInTheDocument(); - }); - - it('displays the correct number of commands', () => { - renderComponent(); - - expect(screen.getAllByTestId(TEST_IDS.command).length).toBe(fakeCommands.length); - }); - - it('displays the right information for each command', () => { - renderComponent(); - - const commands = screen.getAllByTestId(TEST_IDS.command); - commands.forEach(command => expect(command.textContent).toMatchSnapshot()); - }); - - it('lets user switch chain if command is executable and connected wallet is on the wrong chain and command', async () => { - const switchChainMock = vi.fn(); - (useSwitchChain as Vi.Mock).mockImplementation(() => ({ - switchChain: switchChainMock, - })); - - const executableCommand = fakeCommands[3]; - - renderComponent(); - - // Check warning message is displayed - expect( - screen.getByText( - en.voteProposalUi.command.description.wrongChain.replace( - '{{chainName}}', - chainMetadata[executableCommand.chainId].name, - ), - ), - ).toBeInTheDocument(); - - // Click on switch chain button - const switchChainButton = screen.getAllByText( - en.voteProposalUi.command.cta.wrongChain.replace( - '{{chainName}}', - chainMetadata[executableCommand.chainId].name, - ), - )[0]; - - fireEvent.click(switchChainButton); - - await waitFor(() => expect(switchChainMock).toHaveBeenCalledTimes(1)); - expect(switchChainMock).toHaveBeenCalledWith({ chainId: executableCommand.chainId }); - }); - - // TODO: add more tests (see VEN-2701) -}); diff --git a/apps/evm/src/pages/Proposal/__tests__/__snapshots__/index. omnichainGovernance.spec.tsx.snap b/apps/evm/src/pages/Proposal/__tests__/__snapshots__/index.omnichainGovernance.spec.tsx.snap similarity index 100% rename from apps/evm/src/pages/Proposal/__tests__/__snapshots__/index. omnichainGovernance.spec.tsx.snap rename to apps/evm/src/pages/Proposal/__tests__/__snapshots__/index.omnichainGovernance.spec.tsx.snap diff --git a/apps/evm/src/pages/Proposal/__tests__/__snapshots__/index.omnichainGovernance.tsx.snap b/apps/evm/src/pages/Proposal/__tests__/__snapshots__/index.omnichainGovernance.tsx.snap deleted file mode 100644 index 047aed8955..0000000000 --- a/apps/evm/src/pages/Proposal/__tests__/__snapshots__/index.omnichainGovernance.tsx.snap +++ /dev/null @@ -1,35 +0,0 @@ -// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html - -exports[`ProposalUi page - Feature enabled: omnichainGovernance > renders BSC command correctly. Proposal state: +0 1`] = `"CommandsExecuted payloads0/1BNB testnetWaiting for voting to startPending20 Sep 2023 7:39 AMPending until 20 Sep 2023 7:47 AM"`; - -exports[`ProposalUi page - Feature enabled: omnichainGovernance > renders BSC command correctly. Proposal state: 1 1`] = `"CommandsExecuted payloads0/1BNB testnetActive20 Sep 2023 7:47 AMQueueable at 20 Sep 2023 7:49 AM"`; - -exports[`ProposalUi page - Feature enabled: omnichainGovernance > renders BSC command correctly. Proposal state: 2 1`] = `"CommandsExecuted payloads0/1BNB testnetPayload execution cancelled by governance guardianCanceled"`; - -exports[`ProposalUi page - Feature enabled: omnichainGovernance > renders BSC command correctly. Proposal state: 3 1`] = `"CommandsExecuted payloads0/1BNB testnetDefeated20 Sep 2023 7:54 AM"`; - -exports[`ProposalUi page - Feature enabled: omnichainGovernance > renders BSC command correctly. Proposal state: 4 1`] = `"CommandsExecuted payloads0/1BNB testnetQueueQueue"`; - -exports[`ProposalUi page - Feature enabled: omnichainGovernance > renders BSC command correctly. Proposal state: 5 1`] = `"CommandsExecuted payloads0/1BNB testnetWaiting for queueing period to endQueued20 Sep 2023 9:54 AMExecutable at 20 Sep 2023 7:49 AM"`; - -exports[`ProposalUi page - Feature enabled: omnichainGovernance > renders BSC command correctly. Proposal state: 5 2`] = `"CommandsExecuted payloads0/1BNB testnetExecuteExecute"`; - -exports[`ProposalUi page - Feature enabled: omnichainGovernance > renders BSC command correctly. Proposal state: 6 1`] = `"CommandsExecuted payloads0/1BNB testnetExpired20 Sep 2023 7:49 AM"`; - -exports[`ProposalUi page - Feature enabled: omnichainGovernance > renders BSC command correctly. Proposal state: 7 1`] = `"CommandsAll payloads executedBNB testnetExecuted20 Sep 2023 7:49 AM"`; - -exports[`ProposalUi page - Feature enabled: omnichainGovernance > renders description correctly 1`] = `"DescriptionThis vip implement diamond proxy for the comptroller to divide the comptroller logic into facets. The current implementation of the comptroller is exceeding the max limit of the contract size. To resolve this diamond proxy is implemented."`; - -exports[`ProposalUi page - Feature enabled: omnichainGovernance > renders remote commands correctly. Remote proposal state: +0 1`] = `"CommandsExecuted payloads1/2BNB testnetExecuted20 Sep 2023 7:49 AMBNB testnetWaiting for the BNB testnet payload to be executedPending"`; - -exports[`ProposalUi page - Feature enabled: omnichainGovernance > renders remote commands correctly. Remote proposal state: 1 1`] = `"CommandsExecuted payloads1/2BNB testnetExecuted20 Sep 2023 7:49 AMBNB testnetWaiting for the bridge to propagate the transactionBridged20 Sep 2023 7:49 AM"`; - -exports[`ProposalUi page - Feature enabled: omnichainGovernance > renders remote commands correctly. Remote proposal state: 2 1`] = `"CommandsExecuted payloads1/2BNB testnetExecuted20 Sep 2023 7:49 AMBNB testnetWaiting for queueing period to endQueued20 Sep 2023 7:49 AMExecutable at 20 Sep 2023 7:49 AM"`; - -exports[`ProposalUi page - Feature enabled: omnichainGovernance > renders remote commands correctly. Remote proposal state: 2 2`] = `"CommandsExecuted payloads1/2BNB testnetExecuted20 Sep 2023 7:49 AMBNB testnetConnect walletConnect wallet"`; - -exports[`ProposalUi page - Feature enabled: omnichainGovernance > renders remote commands correctly. Remote proposal state: 3 1`] = `"CommandsExecuted payloads1/2BNB testnetExecuted20 Sep 2023 7:49 AMBNB testnetPayload execution cancelled by governance guardianCanceled20 Sep 2023 7:49 AM"`; - -exports[`ProposalUi page - Feature enabled: omnichainGovernance > renders remote commands correctly. Remote proposal state: 4 1`] = `"CommandsExecuted payloads1/2BNB testnetExecuted20 Sep 2023 7:49 AMBNB testnetExpired20 Sep 2023 7:49 AM"`; - -exports[`ProposalUi page - Feature enabled: omnichainGovernance > renders remote commands correctly. Remote proposal state: 5 1`] = `"CommandsAll payloads executedBNB testnetExecuted20 Sep 2023 7:49 AMBNB testnetExecuted20 Sep 2023 7:49 AM"`; diff --git a/apps/evm/src/pages/Proposal/__tests__/index. omnichainGovernance.spec.tsx b/apps/evm/src/pages/Proposal/__tests__/index.omnichainGovernance.spec.tsx similarity index 100% rename from apps/evm/src/pages/Proposal/__tests__/index. omnichainGovernance.spec.tsx rename to apps/evm/src/pages/Proposal/__tests__/index.omnichainGovernance.spec.tsx diff --git a/apps/evm/src/utilities/generateExplorerUrl.ts b/apps/evm/src/utilities/generateExplorerUrl.ts index 0d84cd4a5f..4806110f72 100644 --- a/apps/evm/src/utilities/generateExplorerUrl.ts +++ b/apps/evm/src/utilities/generateExplorerUrl.ts @@ -3,7 +3,7 @@ import type { ChainId } from 'types'; export type UrlType = 'address' | 'token' | 'tx' | 'layerZeroTx'; -export interface generateExplorerUrlInput { +export interface GenerateChainExplorerUrlInput { hash: string; chainId: ChainId; urlType?: T; @@ -18,7 +18,7 @@ export const generateExplorerUrl = ({ hash, urlType, chainId, -}: generateExplorerUrlInput) => { +}: GenerateChainExplorerUrlInput) => { const safeUrlType = urlType || 'address'; if (safeUrlType === 'layerZeroTx') { diff --git a/apps/evm/src/utilities/getProposalState/__tests__/index.spec.ts b/apps/evm/src/utilities/getProposalState/__tests__/index.spec.ts index 034f2916d5..5a2c6a8a8f 100644 --- a/apps/evm/src/utilities/getProposalState/__tests__/index.spec.ts +++ b/apps/evm/src/utilities/getProposalState/__tests__/index.spec.ts @@ -1,5 +1,5 @@ import BigNumber from 'bignumber.js'; -import { PROPOSAL_EXECUTION_GRACE_PERIOD_MS } from 'constants/chainMetadata'; +import { PROPOSAL_EXECUTION_GRACE_PERIOD_MS } from 'constants/governance'; import { ProposalState } from 'types'; import { type GetProposalStateInput, getProposalState } from '..'; diff --git a/apps/evm/src/utilities/getProposalState/index.ts b/apps/evm/src/utilities/getProposalState/index.ts index 26017b888f..f057794bff 100644 --- a/apps/evm/src/utilities/getProposalState/index.ts +++ b/apps/evm/src/utilities/getProposalState/index.ts @@ -1,5 +1,5 @@ import type BigNumber from 'bignumber.js'; -import { PROPOSAL_EXECUTION_GRACE_PERIOD_MS } from 'constants/chainMetadata'; +import { PROPOSAL_EXECUTION_GRACE_PERIOD_MS } from 'constants/governance'; import { ProposalState } from 'types'; export interface GetProposalStateInput { 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/packages/chains/src/chainMetadata.ts b/packages/chains/src/chainMetadata.ts index 13013ca55b..1374cf3366 100644 --- a/packages/chains/src/chainMetadata.ts +++ b/packages/chains/src/chainMetadata.ts @@ -8,8 +8,6 @@ import bnbTokenLogo from './img/tokens/bnb.svg'; import ethTokenLogo from './img/tokens/eth.svg'; import { ChainId, type ChainMetadata, type Token } from './types'; -export const PROPOSAL_EXECUTION_GRACE_PERIOD_MS = 14 * 24 * 60 * 60 * 1000; // 14 days in milliseconds - // TODO: import from @venusprotocol/tokens package once it's been created const bnbToken: Token = { address: '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE', @@ -38,13 +36,7 @@ export const chainMetadata: { blockTimeMs: 3000, blocksPerDay: 28800, 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/QmRCMZJjxi3oKCtbh5CY4gBT2E21Cbz65DAzmnKMNPNGLV', }, [ChainId.BSC_TESTNET]: { name: 'BNB testnet', @@ -54,13 +46,7 @@ export const chainMetadata: { blockTimeMs: 3000, blocksPerDay: 28800, 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/64786/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,11 +57,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', - governanceSubgraphUrl: - 'https://open-platform-ap.nodereal.io/7fab7575d1c34150a9ee582167ffac6f/opbnb-mainnet-graph-query/subgraphs/name/venusprotocol/venus-governance-opbnb', }, [ChainId.OPBNB_TESTNET]: { name: 'opBNB testnet', @@ -86,7 +67,6 @@ export const chainMetadata: { blocksPerDay: 86400, corePoolComptrollerContractAddress: '0x2FCABb31E57F010D623D8d68e1E18Aed11d5A388', nativeToken: bnbToken, - rpcUrl: 'https://opbnb-testnet.nodereal.io/v1/7fab7575d1c34150a9ee582167ffac6f', }, [ChainId.ETHEREUM]: { name: 'Ethereum', @@ -99,11 +79,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', - governanceSubgraphUrl: - 'https://gateway.thegraph.com/api/43fa98f50f96a8e1b63423e8ead8c6dc/deployments/id/QmUXMrtcyqXtzgHVQ8VAtsUJMKuDr7gk9WhHUgertioVZY', }, [ChainId.SEPOLIA]: { name: 'Sepolia', @@ -116,11 +91,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', - governanceSubgraphUrl: - 'https://api.studio.thegraph.com/query/64786/venus-governance-sepolia/version/latest', }, [ChainId.ARBITRUM_ONE]: { name: 'Arbitrum One', @@ -131,11 +101,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', - governanceSubgraphUrl: - 'https://gateway.thegraph.com/api/43fa98f50f96a8e1b63423e8ead8c6dc/deployments/id/QmfUtsb2bQvFnPhxTNYemvQB3qqKvm27rZRFwm2X6yajyh', }, [ChainId.ARBITRUM_SEPOLIA]: { name: 'Arbitrum Sepolia', @@ -146,25 +111,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', - governanceSubgraphUrl: - 'https://api.studio.thegraph.com/query/64786/venus-governance-arbisepolia/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', - governanceSubgraphUrl: - 'https://api.studio.thegraph.com/query/64786/venus-governance-zksyncsepolia/version/latest', }, [ChainId.ZKSYNC_MAINNET]: { name: 'zkSync', @@ -173,11 +119,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', - governanceSubgraphUrl: - 'https://gateway.thegraph.com/api/43fa98f50f96a8e1b63423e8ead8c6dc/deployments/id/QmcdLyjbM4bLv8TEHuCcBgWrJc1nh4b6mhKSZnz2DMGAhU', + }, + [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', @@ -186,11 +135,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', - governanceSubgraphUrl: - 'https://gateway.thegraph.com/api/43fa98f50f96a8e1b63423e8ead8c6dc/deployments/id/QmdTVnzZrFhVn3Q158b3E2rNPFPmEEfyQwgN3im2GbCQLy', }, [ChainId.OPTIMISM_SEPOLIA]: { name: 'Optimism Sepolia', @@ -199,10 +143,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', - governanceSubgraphUrl: - 'https://api.studio.thegraph.com/query/64786/venus-governance-opsepolia/version/latest', }, }; 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 bece112f7c..ff256f291e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1339,6 +1339,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" @@ -8762,6 +8777,11 @@ commander@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" @@ -9596,6 +9616,11 @@ dotenv@^16.0.3: resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-16.4.5.tgz#cdd3b3b604cb327e286b4762e13502f717cb099f" integrity sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg== +dotenv@^16.4.5: + version "16.4.7" + resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-16.4.7.tgz#0e20c5b82950140aa99be360a8a5f52335f53c26" + integrity sha512-47qPchRCykZC03FhkYAhrvwU4xDBFIj1QPqaarj6mdM/hgUzfPHcpkHJOn3mJAufFeeAxAzeGsr5X0M4k6fLZQ== + dset@^3.1.1, dset@^3.1.2: version "3.1.4" resolved "https://registry.yarnpkg.com/dset/-/dset-3.1.4.tgz#f8eaf5f023f068a036d08cd07dc9ffb7d0065248" @@ -9616,7 +9641,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== @@ -10424,6 +10449,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" @@ -14309,6 +14339,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"