hardhat.config.ts 3.43 KB
Newer Older
1 2
import assert from 'assert'

3 4
import { HardhatUserConfig, subtask } from 'hardhat/config'
import { TASK_COMPILE_SOLIDITY_GET_SOURCE_PATHS } from 'hardhat/builtin-tasks/task-names'
5 6 7
import { getenv } from '@eth-optimism/core-utils'
import * as dotenv from 'dotenv'

8 9
import { configSpec } from './src/config/deploy'

10 11 12 13
// Hardhat plugins
import '@nomiclabs/hardhat-ethers'
import '@nomiclabs/hardhat-waffle'
import '@nomiclabs/hardhat-etherscan'
14
import '@eth-optimism/hardhat-deploy-config'
15
import '@typechain/hardhat'
16
import 'solidity-coverage'
17 18
import 'hardhat-gas-reporter'
import 'hardhat-deploy'
19 20 21 22 23 24 25

// Hardhat tasks
import './tasks'

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

26 27 28 29 30 31 32 33
subtask(TASK_COMPILE_SOLIDITY_GET_SOURCE_PATHS).setAction(
  async (_, __, runSuper) => {
    const paths = await runSuper()

    return paths.filter((p: string) => !p.endsWith('.t.sol'))
  }
)

34 35 36 37 38 39 40 41 42
assert(
  !(getenv('PRIVATE_KEY') && getenv('LEDGER_ADDRESS')),
  'use only one of PRIVATE_KEY or LEDGER_ADDRESS'
)

const accounts = getenv('PRIVATE_KEY')
  ? [getenv('PRIVATE_KEY')]
  : (undefined as any)

43 44 45 46
const config: HardhatUserConfig = {
  networks: {
    optimism: {
      chainId: 10,
47
      url: 'https://mainnet.optimism.io',
48
      accounts,
49 50 51 52 53
      verify: {
        etherscan: {
          apiKey: getenv('OPTIMISTIC_ETHERSCAN_API_KEY'),
        },
      },
54
    },
55
    'optimism-kovan': {
56 57
      chainId: 69,
      url: 'https://kovan.optimism.io',
58
      accounts,
59 60 61 62 63
      verify: {
        etherscan: {
          apiKey: getenv('OPTIMISTIC_ETHERSCAN_API_KEY'),
        },
      },
64
    },
65 66 67
    'optimism-goerli': {
      chainId: 420,
      url: 'https://goerli.optimism.io',
68
      accounts,
69 70 71 72 73 74
      verify: {
        etherscan: {
          apiKey: getenv('OPTIMISTIC_ETHERSCAN_API_KEY'),
        },
      },
    },
75
    ethereum: {
76
      chainId: 1,
77
      url: `https://mainnet.infura.io/v3/${getenv('INFURA_PROJECT_ID')}`,
78
      accounts,
79 80 81 82 83 84 85 86 87
      verify: {
        etherscan: {
          apiKey: getenv('ETHEREUM_ETHERSCAN_API_KEY'),
        },
      },
    },
    goerli: {
      chainId: 5,
      url: `https://goerli.infura.io/v3/${getenv('INFURA_PROJECT_ID')}`,
88
      accounts,
89 90 91 92 93 94 95 96 97
      verify: {
        etherscan: {
          apiKey: getenv('ETHEREUM_ETHERSCAN_API_KEY'),
        },
      },
    },
    ropsten: {
      chainId: 3,
      url: `https://ropsten.infura.io/v3/${getenv('INFURA_PROJECT_ID')}`,
98
      accounts,
99 100 101 102 103 104 105 106 107
      verify: {
        etherscan: {
          apiKey: getenv('ETHEREUM_ETHERSCAN_API_KEY'),
        },
      },
    },
    kovan: {
      chainId: 42,
      url: `https://kovan.infura.io/v3/${getenv('INFURA_PROJECT_ID')}`,
108
      accounts,
109 110 111 112 113
      verify: {
        etherscan: {
          apiKey: getenv('ETHEREUM_ETHERSCAN_API_KEY'),
        },
      },
114 115
    },
  },
116 117 118 119
  paths: {
    deployConfig: './config/deploy',
  },
  deployConfigSpec: configSpec,
120 121 122
  mocha: {
    timeout: 50000,
  },
123 124 125 126
  typechain: {
    outDir: 'dist/types',
    target: 'ethers-v5',
  },
127 128
  solidity: {
    compilers: [
129 130 131 132 133 134
      {
        version: '0.8.15',
        settings: {
          optimizer: { enabled: true, runs: 10_000 },
        },
      },
135 136 137 138 139 140 141 142 143 144 145 146
    ],
    settings: {
      metadata: {
        bytecodeHash: 'none',
      },
      outputSelection: {
        '*': {
          '*': ['metadata', 'storageLayout'],
        },
      },
    },
  },
147
  namedAccounts: {
148
    deployer: {
149 150 151
      default: getenv('LEDGER_ADDRESS')
        ? `ledger://${getenv('LEDGER_ADDRESS')}`
        : 0,
152 153
      hardhat: 0,
    },
154 155 156 157
  },
}

export default config