|
| 1 | +import { vars } from 'hardhat/config' |
| 2 | + |
| 3 | +import type { HardhatUserConfig, NetworksUserConfig, ProjectPathsUserConfig, SolidityUserConfig } from 'hardhat/types' |
| 4 | +import type { EtherscanConfig } from '@nomicfoundation/hardhat-verify/types' |
| 5 | + |
| 6 | +// This next import ensures secure accounts config is correctly typed |
| 7 | +// eslint-disable-next-line @typescript-eslint/no-unused-vars |
| 8 | +import type { SecureAccountsOptions } from 'hardhat-secure-accounts/src/type-extensions' |
| 9 | + |
| 10 | +// Environment variables |
| 11 | +const ARBISCAN_API_KEY = vars.get('ARBISCAN_API_KEY', undefined) |
| 12 | + |
| 13 | +// RPCs |
| 14 | +const VIRTUAL_ARBITRUM_SEPOLIA_RPC = vars.has('VIRTUAL_ARBITRUM_SEPOLIA_RPC') ? vars.get('VIRTUAL_ARBITRUM_SEPOLIA_RPC') : undefined |
| 15 | +const ARBITRUM_SEPOLIA_RPC = vars.get('ARBITRUM_SEPOLIA_RPC', 'https://sepolia-rollup.arbitrum.io/rpc') |
| 16 | + |
| 17 | +// Accounts |
| 18 | +const DEPLOYER_PRIVATE_KEY = vars.get('DEPLOYER_PRIVATE_KEY', undefined) |
| 19 | +const GOVERNOR_PRIVATE_KEY = vars.get('GOVERNOR_PRIVATE_KEY', undefined) |
| 20 | +const getTestnetAccounts = () => { |
| 21 | + const accounts: string[] = [] |
| 22 | + if (DEPLOYER_PRIVATE_KEY) accounts.push(DEPLOYER_PRIVATE_KEY) |
| 23 | + if (GOVERNOR_PRIVATE_KEY) accounts.push(GOVERNOR_PRIVATE_KEY) |
| 24 | + return accounts.length > 0 ? accounts : undefined |
| 25 | +} |
| 26 | +const getHardhatAccounts = () => { |
| 27 | + return { |
| 28 | + mnemonic: 'myth like bonus scare over problem client lizard pioneer submit female collect', |
| 29 | + } |
| 30 | +} |
| 31 | + |
| 32 | +export const solidityUserConfig: SolidityUserConfig = { |
| 33 | + version: '0.8.27', |
| 34 | + settings: { |
| 35 | + optimizer: { |
| 36 | + enabled: true, |
| 37 | + runs: 1, |
| 38 | + }, |
| 39 | + }, |
| 40 | +} |
| 41 | + |
| 42 | +export const projectPathsUserConfig: ProjectPathsUserConfig = { |
| 43 | + artifacts: './build/contracts', |
| 44 | + sources: './contracts', |
| 45 | +} |
| 46 | + |
| 47 | +export const etherscanUserConfig: Partial<EtherscanConfig> = { |
| 48 | + apiKey: { |
| 49 | + arbitrumSepolia: ARBISCAN_API_KEY, |
| 50 | + }, |
| 51 | + customChains: [ |
| 52 | + { |
| 53 | + network: 'arbitrumSepolia', |
| 54 | + chainId: 421614, |
| 55 | + urls: { apiURL: 'https://api-sepolia.arbiscan.io/api', browserURL: 'https://sepolia.arbiscan.io/' }, |
| 56 | + }, |
| 57 | + ], |
| 58 | +} |
| 59 | + |
| 60 | +// In general: |
| 61 | +// - hardhat is used for unit tests |
| 62 | +// - localhost is used for local development on a hardhat network or fork |
| 63 | +// - virtualArbitrumSepolia is for Tenderly Virtual Testnet |
| 64 | +export const networksUserConfig: NetworksUserConfig = { |
| 65 | + hardhat: { |
| 66 | + chainId: 31337, |
| 67 | + accounts: getHardhatAccounts(), |
| 68 | + }, |
| 69 | + localhost: { |
| 70 | + chainId: 31337, |
| 71 | + url: 'http://localhost:8545', |
| 72 | + accounts: getTestnetAccounts(), |
| 73 | + }, |
| 74 | + arbitrumSepolia: { |
| 75 | + chainId: 421614, |
| 76 | + url: ARBITRUM_SEPOLIA_RPC, |
| 77 | + secureAccounts: { |
| 78 | + enabled: true, |
| 79 | + }, |
| 80 | + }, |
| 81 | + ...(VIRTUAL_ARBITRUM_SEPOLIA_RPC && { |
| 82 | + virtualArbitrumSepolia: { |
| 83 | + chainId: 421615, |
| 84 | + url: VIRTUAL_ARBITRUM_SEPOLIA_RPC, |
| 85 | + accounts: getTestnetAccounts(), |
| 86 | + }, |
| 87 | + }), |
| 88 | +} |
| 89 | + |
| 90 | +export const hardhatBaseConfig: HardhatUserConfig & { etherscan: Partial<EtherscanConfig> } = { |
| 91 | + solidity: solidityUserConfig, |
| 92 | + paths: projectPathsUserConfig, |
| 93 | + secureAccounts: { |
| 94 | + enabled: false, |
| 95 | + }, |
| 96 | + networks: networksUserConfig, |
| 97 | + graph: { |
| 98 | + deployments: { |
| 99 | + horizon: { |
| 100 | + addressBook: 'addresses.json', |
| 101 | + }, |
| 102 | + }, |
| 103 | + }, |
| 104 | + etherscan: etherscanUserConfig, |
| 105 | +} |
| 106 | + |
| 107 | +export default hardhatBaseConfig |
0 commit comments