• Karl Floersch's avatar
    feat: set gpo task · 4736eb2e
    Karl Floersch authored
    Creates a task that can set the owner of any contract that is `Ownable`.
    It defaults to attempting to set the address of the `OVM_GasPriceOracle`
    on L2. The following config options must be set:
    
    - `CONTRACTS_RPC_URL`
    - `CONTRACTS_DEPLOYER_KEY`
    
    It can be invoked like so:
    
    ```
    $ npx hardhat set-owner --owner 0x..
    ```
    
    On L2 networks that do not enforce transaction fees, the
    `--transaction-gas-price 0` config option may be used for
    convenience.
    
    This script also supports Ledger with the `--use-ledger` flag.
    It defaults to deriving a key at the `ethers.utils.defaultPath`.
    4736eb2e
hardhat.config.ts 2.08 KB
import { HardhatUserConfig } from 'hardhat/types'
import 'solidity-coverage'
import * as dotenv from 'dotenv'

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

// Hardhat plugins
import '@nomiclabs/hardhat-ethers'
import '@nomiclabs/hardhat-waffle'
import 'hardhat-deploy'
import '@typechain/hardhat'
import '@eth-optimism/hardhat-ovm'
import './tasks/deploy'
import './tasks/l2-gasprice'
import './tasks/set-owner'
import 'hardhat-gas-reporter'

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

const enableGasReport = !!process.env.ENABLE_GAS_REPORT

const config: HardhatUserConfig = {
  networks: {
    hardhat: {
      accounts: DEFAULT_ACCOUNTS_HARDHAT,
      blockGasLimit: RUN_OVM_TEST_GAS * 2,
      live: false,
      saveDeployments: false,
      tags: ['local'],
      hardfork: 'istanbul',
    },
    // Add this network to your config!
    optimism: {
      url: 'http://127.0.0.1:8545',
      ovm: true,
      saveDeployments: false,
    },
  },
  mocha: {
    timeout: 50000,
  },
  solidity: {
    version: '0.7.6',
    settings: {
      optimizer: { enabled: true, runs: 200 },
      metadata: {
        bytecodeHash: 'none',
      },
      outputSelection: {
        '*': {
          '*': ['storageLayout'],
        },
      },
    },
  },
  ovm: {
    solcVersion: '0.7.6+commit.3b061308',
  },
  typechain: {
    outDir: 'dist/types',
    target: 'ethers-v5',
  },
  paths: {
    deploy: './deploy',
    deployments: './deployments',
  },
  namedAccounts: {
    deployer: {
      default: 0,
    },
  },
  gasReporter: {
    enabled: enableGasReport,
    currency: 'USD',
    gasPrice: 100,
    outputFile: process.env.CI ? 'gas-report.txt' : undefined,
  },
}

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],
  }
}

export default config