import * as dotenv from "dotenv"; import path from 'path'; import fs from 'fs'; import { HardhatUserConfig, } from "hardhat/config"; import "@nomiclabs/hardhat-etherscan"; import "@nomiclabs/hardhat-waffle"; import "@nomiclabs/hardhat-ethers"; import "@typechain/hardhat"; import "hardhat-gas-reporter"; import "solidity-coverage"; import 'hardhat-deploy'; import { Wallet } from "ethers"; dotenv.config(); if (process.env.SKIP_LOAD !== 'true') { // eslint-disable-next-line global-require [''].forEach((folder) => { const tasksPath = path.join(__dirname, 'tasks', folder); fs.readdirSync(tasksPath) .filter((pth) => pth.includes('.ts')) .forEach((task) => { require(`${tasksPath}/${task}`); }); }); } const HARDFORK = 'istanbul'; const MNEMONIC_PATH = "m/44'/60'/0'/0"; const MNEMONIC = process.env.MNEMONIC || 'fox sight canyon orphan hotel grow hedgehog build bless august weather swarm'; const INFURA_KEY = process.env.INFURA_KEY || ''; const ALCHEMY_KEY = process.env.ALCHEMY_KEY || ''; const MAINNET_FORK = process.env.MAINNET_FORK === 'true'; const FORKING_BLOCK = parseInt(process.env.FORKING_BLOCK || '') const mainnetFork = MAINNET_FORK && FORKING_BLOCK ? { blockNumber: FORKING_BLOCK, url: ALCHEMY_KEY ? `https://eth-mainnet.alchemyapi.io/v2/${ALCHEMY_KEY}` : `https://main.infura.io/v3/${INFURA_KEY}`, } : undefined; const getCommonNetworkConfig = (networkName: string, networkId: number) => ({ url: ALCHEMY_KEY ? `https://eth-${networkName === 'main' ? 'mainnet' : networkName }.alchemyapi.io/v2/${ALCHEMY_KEY}` : `https://${networkName}.infura.io/v3/${INFURA_KEY}`, hardfork: HARDFORK, chainId: networkId, accounts: { mnemonic: MNEMONIC, path: MNEMONIC_PATH, initialIndex: 0, count: 20, }, }); const accounts = Array.from(Array(20), (_, index) => { const wallet = Wallet.fromMnemonic(MNEMONIC, `m/44'/60'/0'/0/${index}`); return { privateKey: wallet.privateKey, balance: '1000000000000000000000000' } }) const LOCAL_CHAIN_ID = 31337; const config: HardhatUserConfig = { solidity: { compilers: [ { version: '0.8.4', settings: { optimizer: { enabled: true, runs: 200 }, evmVersion: 'berlin', }, }, { version: '0.6.11', }, { version: '0.7.3', }, ], }, typechain: { outDir: 'types', }, etherscan: { apiKey: process.env.INFURA_KEY, }, defaultNetwork: 'hardhat', paths: { sources: "./packages/verifier-contracts" }, networks: { kovan: getCommonNetworkConfig('kovan', 42), ropsten: getCommonNetworkConfig('ropsten', 3), rinkeby: getCommonNetworkConfig('rinkeby', 4), main: getCommonNetworkConfig('main', 1), local: { live: false, saveDeployments: false, url: 'http://localhost:8545', accounts: accounts.map(account => account.privateKey), hardfork: HARDFORK, chainId: LOCAL_CHAIN_ID, }, hardhat: { live: false, hardfork: 'london', chainId: LOCAL_CHAIN_ID, throwOnTransactionFailures: true, throwOnCallFailures: true, accounts, forking: mainnetFork, saveDeployments: false }, ganache: { live: false, url: 'http://ganache:8545', accounts: accounts.map(account => account.privateKey), }, coverage: { live: false, url: 'http://localhost:8555', }, }, }; export default config;