|
| 1 | +import * as dotenv from 'dotenv' |
| 2 | +dotenv.config() |
| 3 | + |
| 4 | +import { HardhatUserConfig } from 'hardhat/types' |
| 5 | +import { task } from 'hardhat/config' |
| 6 | + |
| 7 | +// Plugins |
| 8 | + |
| 9 | +import '@nomiclabs/hardhat-ethers' |
| 10 | +import '@nomiclabs/hardhat-etherscan' |
| 11 | +import '@nomiclabs/hardhat-waffle' |
| 12 | +import 'hardhat-abi-exporter' |
| 13 | +import 'hardhat-gas-reporter' |
| 14 | +import 'hardhat-contract-sizer' |
| 15 | +import '@tenderly/hardhat-tenderly' |
| 16 | +import '@openzeppelin/hardhat-upgrades' |
| 17 | +import '@typechain/hardhat' |
| 18 | + |
| 19 | +// Tasks |
| 20 | + |
| 21 | +import './tasks/craft-calldata' |
| 22 | +import './tasks/post-calldata' |
| 23 | + |
| 24 | +// Networks |
| 25 | + |
| 26 | +interface NetworkConfig { |
| 27 | + network: string |
| 28 | + chainId: number |
| 29 | + gas?: number | 'auto' |
| 30 | + gasPrice?: number | 'auto' |
| 31 | + url?: string |
| 32 | +} |
| 33 | + |
| 34 | +const networkConfigs: NetworkConfig[] = [ |
| 35 | + { network: 'mainnet', chainId: 1 }, |
| 36 | + { network: 'ropsten', chainId: 3 }, |
| 37 | + { network: 'rinkeby', chainId: 4 }, |
| 38 | + { network: 'kovan', chainId: 42 }, |
| 39 | + { network: 'sepolia', chainId: 11155111 }, |
| 40 | + { |
| 41 | + network: 'arbitrum-one', |
| 42 | + chainId: 42161, |
| 43 | + url: 'https://arb1.arbitrum.io/rpc', |
| 44 | + }, |
| 45 | + { |
| 46 | + network: 'arbitrum-goerli', |
| 47 | + chainId: 421613, |
| 48 | + url: 'https://goerli-rollup.arbitrum.io/rpc', |
| 49 | + }, |
| 50 | + { |
| 51 | + network: 'arbitrum-sepolia', |
| 52 | + chainId: 421614, |
| 53 | + url: 'https://sepolia-rollup.arbitrum.io/rpcblock', |
| 54 | + }, |
| 55 | +] |
| 56 | + |
| 57 | +function getAccountMnemonic() { |
| 58 | + return process.env.MNEMONIC || '' |
| 59 | +} |
| 60 | + |
| 61 | +function getDefaultProviderURL(network: string) { |
| 62 | + return `https://${network}.infura.io/v3/${process.env.INFURA_KEY}` |
| 63 | +} |
| 64 | + |
| 65 | +function setupDefaultNetworkProviders(buidlerConfig) { |
| 66 | + for (const netConfig of networkConfigs) { |
| 67 | + buidlerConfig.networks[netConfig.network] = { |
| 68 | + chainId: netConfig.chainId, |
| 69 | + url: netConfig.url ? netConfig.url : getDefaultProviderURL(netConfig.network), |
| 70 | + gas: netConfig.gasPrice || 'auto', |
| 71 | + gasPrice: netConfig.gasPrice || 'auto', |
| 72 | + accounts: { |
| 73 | + mnemonic: getAccountMnemonic(), |
| 74 | + }, |
| 75 | + } |
| 76 | + } |
| 77 | +} |
| 78 | + |
| 79 | +// Tasks |
| 80 | + |
| 81 | +task('accounts', 'Prints the list of accounts', async (taskArgs, bre) => { |
| 82 | + const accounts = await bre.ethers.getSigners() |
| 83 | + for (const account of accounts) { |
| 84 | + console.log(await account.getAddress()) |
| 85 | + } |
| 86 | +}) |
| 87 | + |
| 88 | +// Config |
| 89 | +const config: HardhatUserConfig = { |
| 90 | + paths: { |
| 91 | + sources: './contracts', |
| 92 | + tests: './test', |
| 93 | + artifacts: './build/contracts', |
| 94 | + }, |
| 95 | + solidity: { |
| 96 | + compilers: [ |
| 97 | + { |
| 98 | + version: '0.8.12', |
| 99 | + settings: { |
| 100 | + optimizer: { |
| 101 | + enabled: true, |
| 102 | + runs: 200, |
| 103 | + }, |
| 104 | + outputSelection: { |
| 105 | + '*': { |
| 106 | + '*': ['storageLayout'], |
| 107 | + }, |
| 108 | + }, |
| 109 | + }, |
| 110 | + }, |
| 111 | + ], |
| 112 | + }, |
| 113 | + defaultNetwork: 'hardhat', |
| 114 | + networks: { |
| 115 | + hardhat: { |
| 116 | + chainId: 1337, |
| 117 | + loggingEnabled: false, |
| 118 | + gas: 1200000, |
| 119 | + gasPrice: 'auto', |
| 120 | + blockGasLimit: 12000000, |
| 121 | + accounts: { |
| 122 | + mnemonic: 'myth like bonus scare over problem client lizard pioneer submit female collect', |
| 123 | + }, |
| 124 | + mining: { |
| 125 | + auto: true, |
| 126 | + interval: 0, |
| 127 | + }, |
| 128 | + }, |
| 129 | + ganache: { |
| 130 | + chainId: 1337, |
| 131 | + url: 'http://localhost:8545', |
| 132 | + }, |
| 133 | + }, |
| 134 | + etherscan: { |
| 135 | + apiKey: { |
| 136 | + mainnet: process.env.ETHERSCAN_API_KEY, |
| 137 | + goerli: process.env.ETHERSCAN_API_KEY, |
| 138 | + sepolia: process.env.ETHERSCAN_API_KEY, |
| 139 | + arbitrumOne: process.env.ARBISCAN_API_KEY, |
| 140 | + arbitrumGoerli: process.env.ARBISCAN_API_KEY, |
| 141 | + arbitrumSepolia: process.env.ARBISCAN_API_KEY, |
| 142 | + }, |
| 143 | + customChains: [ |
| 144 | + { |
| 145 | + network: 'arbitrumSepolia', |
| 146 | + chainId: 421614, |
| 147 | + urls: { |
| 148 | + apiURL: 'https://api-sepolia.arbiscan.io/api', |
| 149 | + browserURL: 'https://sepolia.arbiscan.io', |
| 150 | + }, |
| 151 | + }, |
| 152 | + ], |
| 153 | + }, |
| 154 | + gasReporter: { |
| 155 | + enabled: process.env.REPORT_GAS ? true : false, |
| 156 | + showTimeSpent: true, |
| 157 | + currency: 'USD', |
| 158 | + outputFile: 'reports/gas-report.log', |
| 159 | + }, |
| 160 | + typechain: { |
| 161 | + outDir: 'build/types', |
| 162 | + target: 'ethers-v5', |
| 163 | + }, |
| 164 | + abiExporter: { |
| 165 | + path: './build/abis', |
| 166 | + clear: false, |
| 167 | + flat: true, |
| 168 | + }, |
| 169 | + tenderly: { |
| 170 | + project: process.env.TENDERLY_PROJECT, |
| 171 | + username: process.env.TENDERLY_USERNAME, |
| 172 | + }, |
| 173 | + contractSizer: { |
| 174 | + alphaSort: true, |
| 175 | + runOnCompile: false, |
| 176 | + disambiguatePaths: true, |
| 177 | + }, |
| 178 | +} |
| 179 | + |
| 180 | +setupDefaultNetworkProviders(config) |
| 181 | + |
| 182 | +export default config |
0 commit comments