hardhat.config.ts 3.7 KB
Newer Older
1
import { HardhatUserConfig } from 'hardhat/types'
2
import 'solidity-coverage'
3
import * as dotenv from 'dotenv'
4 5 6 7 8 9 10 11 12

import {
  DEFAULT_ACCOUNTS_HARDHAT,
  RUN_OVM_TEST_GAS,
} from './test/helpers/constants'

// Hardhat plugins
import '@nomiclabs/hardhat-ethers'
import '@nomiclabs/hardhat-waffle'
13
import '@nomiclabs/hardhat-etherscan'
14
import 'hardhat-deploy'
15
import '@typechain/hardhat'
Guang Chen's avatar
Guang Chen committed
16
import './tasks'
17
import 'hardhat-gas-reporter'
18
import '@primitivefi/hardhat-dodoc'
19
import 'hardhat-output-validator'
20 21 22

// Load environment variables from .env
dotenv.config()
23

24
const enableGasReport = !!process.env.ENABLE_GAS_REPORT
25
const privateKey = process.env.PRIVATE_KEY || '0x' + '11'.repeat(32) // this is to avoid hardhat error
26
const deploy = process.env.DEPLOY_DIRECTORY || 'deploy'
27

28 29 30 31 32
const config: HardhatUserConfig = {
  networks: {
    hardhat: {
      accounts: DEFAULT_ACCOUNTS_HARDHAT,
      blockGasLimit: RUN_OVM_TEST_GAS * 2,
33 34 35
      live: false,
      saveDeployments: false,
      tags: ['local'],
36
    },
37 38
    optimism: {
      url: 'http://127.0.0.1:8545',
39
      saveDeployments: false,
40
    },
41 42 43
    'optimism-kovan': {
      chainId: 69,
      url: 'https://kovan.optimism.io',
44
      deploy,
45
      accounts: [privateKey],
46 47 48 49
    },
    'optimism-mainnet': {
      chainId: 10,
      url: 'https://mainnet.optimism.io',
50
      deploy,
51 52
      accounts: [privateKey],
    },
53 54 55 56 57
    'mainnet-trial': {
      chainId: 42069,
      url: 'http://127.0.0.1:8545',
      accounts: [privateKey],
    },
58 59 60 61 62 63 64 65 66 67 68 69
    kovan: {
      chainId: 42,
      url: process.env.CONTRACTS_RPC_URL || '',
      deploy,
      accounts: [privateKey],
    },
    mainnet: {
      chainId: 1,
      url: process.env.CONTRACTS_RPC_URL || '',
      deploy,
      accounts: [privateKey],
    },
70 71 72 73 74
  },
  mocha: {
    timeout: 50000,
  },
  solidity: {
75 76
    compilers: [
      {
rajivpoc's avatar
rajivpoc committed
77
        version: '0.8.9',
78
        settings: {
79
          optimizer: { enabled: true, runs: 10_000 },
80
        },
81 82 83
      },
      {
        version: '0.5.17', // Required for WETH9
84
        settings: {
85
          optimizer: { enabled: true, runs: 10_000 },
86 87
        },
      },
88
    ],
89 90 91 92 93 94 95 96 97 98
    settings: {
      metadata: {
        bytecodeHash: 'none',
      },
      outputSelection: {
        '*': {
          '*': ['metadata', 'storageLayout'],
        },
      },
    },
99 100 101 102 103
  },
  typechain: {
    outDir: 'dist/types',
    target: 'ethers-v5',
  },
104 105 106 107 108 109 110 111 112
  paths: {
    deploy: './deploy',
    deployments: './deployments',
  },
  namedAccounts: {
    deployer: {
      default: 0,
    },
  },
113 114 115 116 117 118
  gasReporter: {
    enabled: enableGasReport,
    currency: 'USD',
    gasPrice: 100,
    outputFile: process.env.CI ? 'gas-report.txt' : undefined,
  },
119 120 121
  etherscan: {
    apiKey: process.env.ETHERSCAN_API_KEY,
  },
122 123
  dodoc: {
    runOnCompile: true,
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140
    exclude: [
      'Helper_GasMeasurer',
      'Helper_SimpleProxy',
      'TestERC20',
      'TestLib_CrossDomainUtils',
      'TestLib_OVMCodec',
      'TestLib_RLPReader',
      'TestLib_RLPWriter',
      'TestLib_AddressAliasHelper',
      'TestLib_MerkleTrie',
      'TestLib_SecureMerkleTrie',
      'TestLib_Buffer',
      'TestLib_Bytes32Utils',
      'TestLib_BytesUtils',
      'TestLib_MerkleTree',
    ],
  },
141
  outputValidator: {
142
    runOnCompile: true,
Indeavr's avatar
Indeavr committed
143
    errorMode: false,
144
    checks: {
145 146
      events: false,
      variables: false,
147
    },
148 149
    exclude: ['contracts/test-helpers', 'contracts/test-libraries'],
  },
150 151 152 153 154 155 156 157 158 159 160 161 162 163
}

if (
  process.env.CONTRACTS_TARGET_NETWORK &&
  process.env.CONTRACTS_DEPLOYER_KEY &&
  process.env.CONTRACTS_RPC_URL
) {
  config.networks[process.env.CONTRACTS_TARGET_NETWORK] = {
    accounts: [process.env.CONTRACTS_DEPLOYER_KEY],
    url: process.env.CONTRACTS_RPC_URL,
    live: true,
    saveDeployments: true,
    tags: [process.env.CONTRACTS_TARGET_NETWORK],
  }
164 165 166
}

export default config