From f759c6dd8c3994bd8e50ecf307ea4ce5fed62549 Mon Sep 17 00:00:00 2001 From: GopherJ Date: Fri, 5 Jan 2024 16:04:28 +0800 Subject: [PATCH] feat: add neon & parallel Signed-off-by: GopherJ --- hardhat.config.ts | 42 +++++++++++++++++++++--------------- helper-hardhat-config.ts | 7 +++++- helpers/hardhat-constants.ts | 14 +++++++++++- helpers/misc-utils.ts | 22 ++++++++++++++++++- helpers/types.ts | 2 ++ market-config/index.ts | 2 ++ 6 files changed, 69 insertions(+), 20 deletions(-) diff --git a/hardhat.config.ts b/hardhat.config.ts index f85028fb..112b0d42 100644 --- a/hardhat.config.ts +++ b/hardhat.config.ts @@ -30,6 +30,8 @@ import { SEPOLIA_ETHERSCAN_KEY, ARBITRUM_SEPOLIA_ETHERSCAN_KEY, PARAX_DEV_ETHERSCAN_KEY, + NEON_ETHERSCAN_KEY, + PARALLEL_ETHERSCAN_KEY, } from "./helpers/hardhat-constants"; import {accounts} from "./wallets"; import {accounts as evmAccounts} from "./evm-wallets"; @@ -152,13 +154,23 @@ const hardhatConfig: HardhatUserConfig = { allowUnlimitedContractSize: true, timeout: 9000000, }, + hardhat: { + hardfork: HARDFORK, + blockGasLimit: DEFAULT_BLOCK_GAS_LIMIT, + gas: DEFAULT_BLOCK_GAS_LIMIT, + gasPrice: "auto", + chainId: CHAINS_ID[eEthereumNetwork.hardhat], + throwOnTransactionFailures: true, + throwOnCallFailures: true, + accounts, + loggingEnabled: VERBOSE, + forking: buildForkConfig(), + allowUnlimitedContractSize: true, + }, parallel: { url: NETWORKS_RPC_URL[eEthereumNetwork.parallel], chainId: CHAINS_ID[eEthereumNetwork.parallel], - accounts: evmAccounts.map(({privateKey}) => privateKey), - gasPrice: 4e9, - gas: 4e6, - allowUnlimitedContractSize: true, + accounts: DEPLOYER, }, moonbeam: { chainId: CHAINS_ID[eEthereumNetwork.moonbeam], @@ -170,19 +182,6 @@ const hardhatConfig: HardhatUserConfig = { url: NETWORKS_RPC_URL[eEthereumNetwork.moonbase], accounts: DEPLOYER, }, - hardhat: { - hardfork: HARDFORK, - blockGasLimit: DEFAULT_BLOCK_GAS_LIMIT, - gas: DEFAULT_BLOCK_GAS_LIMIT, - gasPrice: "auto", - chainId: CHAINS_ID[eEthereumNetwork.hardhat], - throwOnTransactionFailures: true, - throwOnCallFailures: true, - accounts, - loggingEnabled: VERBOSE, - forking: buildForkConfig(), - allowUnlimitedContractSize: true, - }, goerli: { chainId: CHAINS_ID[eEthereumNetwork.goerli], url: NETWORKS_RPC_URL[eEthereumNetwork.goerli], @@ -259,6 +258,11 @@ const hardhatConfig: HardhatUserConfig = { url: NETWORKS_RPC_URL[eEthereumNetwork.lineaGoerli], accounts: DEPLOYER, }, + neon: { + chainId: CHAINS_ID[eEthereumNetwork.neon], + url: NETWORKS_RPC_URL[eEthereumNetwork.neon], + accounts: DEPLOYER, + }, mainnet: { chainId: CHAINS_ID[eEthereumNetwork.mainnet], url: NETWORKS_RPC_URL[eEthereumNetwork.mainnet], @@ -283,6 +287,8 @@ const hardhatConfig: HardhatUserConfig = { moonbase: MOONBASE_ETHERSCAN_KEY, linea: LINEA_ETHERSCAN_KEY, lineaGoerli: LINEA_GOERLI_ETHERSCAN_KEY, + neon: NEON_ETHERSCAN_KEY, + parallel: PARALLEL_ETHERSCAN_KEY, }, customChains: [ eEthereumNetwork.localhost, @@ -302,6 +308,8 @@ const hardhatConfig: HardhatUserConfig = { eEthereumNetwork.moonbase, eEthereumNetwork.linea, eEthereumNetwork.lineaGoerli, + eEthereumNetwork.neon, + eEthereumNetwork.parallel, ].map((network) => ({ network, chainId: CHAINS_ID[network]!, diff --git a/helper-hardhat-config.ts b/helper-hardhat-config.ts index 51d2cf96..a9cc60d2 100644 --- a/helper-hardhat-config.ts +++ b/helper-hardhat-config.ts @@ -30,6 +30,7 @@ import { ZKSYNC_GOERLI_CHAINID, ARBITRUM_SEPOLIA_CHAINID, PARAX_DEV_CHAINID, + NEON_CHAINID, } from "./helpers/hardhat-constants"; dotenv.config(); @@ -75,7 +76,7 @@ export const NETWORKS_RPC_URL: iParamsPerNetwork = { [eEthereumNetwork.ganache]: RPC_URL || "http://localhost:8545", [eEthereumNetwork.tenderlyMain]: RPC_URL || `https://rpc.tenderly.co/fork/${TENDERLY_FORK_ID}`, - [eEthereumNetwork.parallel]: RPC_URL || "http://localhost:29933", + [eEthereumNetwork.parallel]: RPC_URL || "https://rpc.parallel.fi", [eEthereumNetwork.moonbeam]: "https://rpc.api.moonbeam.network", [eEthereumNetwork.moonbase]: "https://rpc.testnet.moonbeam.network", [eEthereumNetwork.arbitrum]: @@ -122,6 +123,8 @@ export const NETWORKS_RPC_URL: iParamsPerNetwork = { (INFURA_KEY ? `https://linea-goerli.infura.io/v3/${INFURA_KEY}` : `https://rpc.goerli.linea.build`), + [eEthereumNetwork.neon]: + RPC_URL || `https://neon-proxy-mainnet.solana.p2p.org`, }; export const CHAINS_ID: iParamsPerNetwork = { @@ -147,6 +150,7 @@ export const CHAINS_ID: iParamsPerNetwork = { [eEthereumNetwork.zksyncGoerli]: ZKSYNC_GOERLI_CHAINID, [eEthereumNetwork.linea]: LINEA_CHAINID, [eEthereumNetwork.lineaGoerli]: LINEA_GOERLI_CHAINID, + [eEthereumNetwork.neon]: NEON_CHAINID, }; export const BLOCK_TO_FORK: iParamsPerNetwork = { @@ -172,4 +176,5 @@ export const BLOCK_TO_FORK: iParamsPerNetwork = { [eEthereumNetwork.zksyncGoerli]: undefined, [eEthereumNetwork.linea]: undefined, [eEthereumNetwork.lineaGoerli]: undefined, + [eEthereumNetwork.neon]: undefined, }; diff --git a/helpers/hardhat-constants.ts b/helpers/hardhat-constants.ts index f3cae37b..b6efcc53 100644 --- a/helpers/hardhat-constants.ts +++ b/helpers/hardhat-constants.ts @@ -25,7 +25,7 @@ export const GOERLI_CHAINID = 5; export const SEPOLIA_CHAINID = 11155111; export const FORK_CHAINID = 522; export const MAINNET_CHAINID = 1; -export const PARALLEL_CHAINID = 1592; +export const PARALLEL_CHAINID = 1024; export const PARAX_DEV_CHAINID = 2982896226593698; export const MOONBEAM_CHAINID = 1284; export const MOONBASE_CHAINID = 1287; @@ -40,6 +40,7 @@ export const ZKSYNC_CHAINID = 324; export const ZKSYNC_GOERLI_CHAINID = 280; export const LINEA_GOERLI_CHAINID = 59140; export const LINEA_CHAINID = 59144; +export const NEON_CHAINID = 245022934; export const INFURA_KEY = process.env.INFURA_KEY || ""; export const ALCHEMY_KEY = process.env.ALCHEMY_KEY || ""; @@ -108,6 +109,11 @@ export const ETHERSCAN_VERIFICATION_JOBS = parseInt( export const ETHERSCAN_VERIFICATION_MAX_RETRIES = parseInt( process.env.ETHERSCAN_VERIFICATION_MAX_RETRIES || "3" ); +export const NEON_ETHERSCAN_KEY = + process.env.NEON_ETHERSCAN_KEY || ETHERSCAN_KEY; +export const PARALLEL_ETHERSCAN_KEY = + process.env.PARALLEL_ETHERSCAN_KEY || ETHERSCAN_KEY; + export const ETHERSCAN_NETWORKS = [ "localhost", "mainnet", @@ -127,6 +133,8 @@ export const ETHERSCAN_NETWORKS = [ "lineaGoerli", "moonbeam", "moonbase", + "neon", + "parallel", ]; export const ETHERSCAN_APIS = { localhost: "http://localhost:4000/api", @@ -149,6 +157,8 @@ export const ETHERSCAN_APIS = { moonbase: "https://api-moonbase.moonscan.io/api", linea: "http://explorer.linea.build/api", lineaGoerli: "https://explorer.goerli.linea.build/api", + neon: "https://neonscan.org/api", + parallel: "https://explorer.parallel.fi/api", }; export const BROWSER_URLS = { localhost: "http://localhost:4000", @@ -170,6 +180,8 @@ export const BROWSER_URLS = { moonbase: "https://moonbase.moonscan.io", linea: "https://explorer.linea.build", lineaGoerli: "https://explorer.goerli.linea.build", + neon: "https://neonscan.org", + parallel: "https://explorer.parallel.fi", }; export const DEPLOY_START = parseInt(process.env.DEPLOY_START || "0"); diff --git a/helpers/misc-utils.ts b/helpers/misc-utils.ts index fad421a0..fa0d3e2d 100644 --- a/helpers/misc-utils.ts +++ b/helpers/misc-utils.ts @@ -31,6 +31,8 @@ import { SEPOLIA_CHAINID, ARBITRUM_SEPOLIA_CHAINID, PARAX_DEV_CHAINID, + NEON_CHAINID, + PARALLEL_CHAINID, } from "./hardhat-constants"; import {ConstructorArgs, eContractid, tEthereumAddress} from "./types"; import dotenv from "dotenv"; @@ -146,6 +148,22 @@ export const isLinea = (): boolean => { ); }; +export const isNeon = (): boolean => { + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + return ( + [NEON_CHAINID].includes(DRE.network.config.chainId!) || + [eEthereumNetwork.neon].includes(FORK as eEthereumNetwork) + ); +}; + +export const isParallel = (): boolean => { + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + return ( + [PARALLEL_CHAINID].includes(DRE.network.config.chainId!) || + [eEthereumNetwork.parallel].includes(FORK as eEthereumNetwork) + ); +}; + export const isMainnet = (): boolean => isEthereum() || isMoonbeam() || @@ -153,7 +171,9 @@ export const isMainnet = (): boolean => isZkSync() || isPolygon() || isPolygonZkEVM() || - isLinea(); + isLinea() || + isNeon() || + isParallel(); export const safeTransactionServiceUrl = (): string => { return isMoonbeam() diff --git a/helpers/types.ts b/helpers/types.ts index 015bd412..8eea650d 100644 --- a/helpers/types.ts +++ b/helpers/types.ts @@ -106,6 +106,7 @@ export enum eEthereumNetwork { zksyncGoerli = "zksyncGoerli", linea = "linea", lineaGoerli = "lineaGoerli", + neon = "neon", } export enum eContractid { @@ -771,6 +772,7 @@ export interface iEthereumParamsPerNetwork { [eEthereumNetwork.zksyncGoerli]: T; [eEthereumNetwork.linea]: T; [eEthereumNetwork.lineaGoerli]: T; + [eEthereumNetwork.neon]: T; } export enum RateMode { diff --git a/market-config/index.ts b/market-config/index.ts index e20c2996..58de81e4 100644 --- a/market-config/index.ts +++ b/market-config/index.ts @@ -1111,4 +1111,6 @@ export const ParaSpaceConfigs: Partial< [eEthereumNetwork.zksyncGoerli]: ZkSyncGoerliConfig, [eEthereumNetwork.linea]: LineaConfig, [eEthereumNetwork.lineaGoerli]: LineaGoerliConfig, + [eEthereumNetwork.parallel]: HardhatConfig, + [eEthereumNetwork.neon]: HardhatConfig, };