Commit dc9cf2b6 authored by Mark Tyneway's avatar Mark Tyneway Committed by GitHub

contracts-governance: clean up the hardhat config (#2989)

* contracts-governance: clean up the hardhat config

Deletes some unused types and cleans up the hh config file

* contracts-governance: more cleanup
Co-authored-by: default avatarmergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
parent eb11a5bb
---
'@eth-optimism/contracts-governance': patch
---
Clean up the hardhat config
import dotenv from 'dotenv' import dotenv from 'dotenv'
import { HardhatUserConfig } from 'hardhat/config'
import '@nomiclabs/hardhat-ethers' import '@nomiclabs/hardhat-ethers'
import '@nomiclabs/hardhat-etherscan' import '@nomiclabs/hardhat-etherscan'
import '@nomiclabs/hardhat-waffle' import '@nomiclabs/hardhat-waffle'
import 'hardhat-gas-reporter' import 'hardhat-gas-reporter'
import 'solidity-coverage' import 'solidity-coverage'
import { task, types } from 'hardhat/config'
import { providers, utils, Wallet } from 'ethers'
import { CrossChainMessenger } from '@eth-optimism/sdk'
import { getChainId } from '@eth-optimism/core-utils'
import './scripts/deploy-token' import './scripts/deploy-token'
import './scripts/multi-send' import './scripts/multi-send'
...@@ -17,66 +14,13 @@ import './scripts/create-airdrop-json' ...@@ -17,66 +14,13 @@ import './scripts/create-airdrop-json'
import './scripts/deploy-distributor' import './scripts/deploy-distributor'
import './scripts/test-claims' import './scripts/test-claims'
import './scripts/create-distributor-json' import './scripts/create-distributor-json'
import './scripts/deposit'
dotenv.config() dotenv.config()
task('accounts', 'Prints the list of accounts').setAction(async (args, hre) => {
const accounts = await hre.ethers.getSigners()
for (const account of accounts) {
console.log(account.address)
}
})
task('deposit', 'Deposits funds onto Optimism.')
.addParam('to', 'Recipient address.', null, types.string)
.addParam('amountEth', 'Amount in ETH to send.', null, types.string)
.addParam('l1ProviderUrl', '', process.env.L1_PROVIDER_URL, types.string)
.addParam('l2ProviderUrl', '', process.env.L2_PROVIDER_URL, types.string)
.addParam('privateKey', '', process.env.PRIVATE_KEY, types.string)
.setAction(async (args) => {
const { to, amountEth, l1ProviderUrl, l2ProviderUrl, privateKey } = args
if (!l1ProviderUrl || !l2ProviderUrl || !privateKey) {
throw new Error(
'You must define --l1-provider-url, --l2-provider-url, --private-key in your environment.'
)
}
const l1Provider = new providers.JsonRpcProvider(l1ProviderUrl)
const l2Provider = new providers.JsonRpcProvider(l2ProviderUrl)
const l1Wallet = new Wallet(privateKey, l1Provider)
const messenger = new CrossChainMessenger({
l1SignerOrProvider: l1Wallet,
l2SignerOrProvider: l2Provider,
l1ChainId: await getChainId(l1Provider),
l2ChainId: await getChainId(l2Provider),
})
const amountWei = utils.parseEther(amountEth)
console.log(`Depositing ${amountEth} ETH to ${to}...`)
const tx = await messenger.depositETH(amountWei, {
recipient: to,
})
console.log(`Got TX hash ${tx.hash}. Waiting...`)
await tx.wait()
const l1WalletOnL2 = new Wallet(privateKey, l2Provider)
await l1WalletOnL2.sendTransaction({
to,
value: utils.parseEther(amountEth),
})
const balance = await l2Provider.getBalance(to)
console.log('Funded account balance', balance.toString())
console.log('Done.')
})
const privKey = process.env.PRIVATE_KEY || '0x' + '11'.repeat(32) const privKey = process.env.PRIVATE_KEY || '0x' + '11'.repeat(32)
/** const config: HardhatUserConfig = {
* @type import("hardhat/config").HardhatUserConfig
*/
module.exports = {
solidity: { solidity: {
version: '0.8.12', version: '0.8.12',
settings: { settings: {
...@@ -91,17 +35,20 @@ module.exports = { ...@@ -91,17 +35,20 @@ module.exports = {
optimism: { optimism: {
chainId: 17, chainId: 17,
url: 'http://localhost:8545', url: 'http://localhost:8545',
saveDeployments: false,
}, },
'optimism-kovan': { 'optimism-kovan': {
chainId: 69, chainId: 69,
url: 'https://kovan.optimism.io', url: 'https://kovan.optimism.io',
accounts: [privKey], accounts: [privKey],
}, },
'optimism-goerli': {
chainId: 420,
url: 'https://goerli.optimism.io',
accounts: [privKey],
},
'optimism-nightly': { 'optimism-nightly': {
chainId: 421, chainId: 421,
url: 'https://goerli-nightly-us-central1-a-sequencer.optimism.io', url: 'https://goerli-nightly-us-central1-a-sequencer.optimism.io',
saveDeployments: true,
accounts: [privKey], accounts: [privKey],
}, },
'optimism-mainnet': { 'optimism-mainnet': {
...@@ -110,8 +57,7 @@ module.exports = { ...@@ -110,8 +57,7 @@ module.exports = {
accounts: [privKey], accounts: [privKey],
}, },
'hardhat-node': { 'hardhat-node': {
url: 'http://localhost:9545', url: 'http://localhost:8545',
saveDeployments: false,
}, },
}, },
gasReporter: { gasReporter: {
...@@ -122,3 +68,5 @@ module.exports = { ...@@ -122,3 +68,5 @@ module.exports = {
apiKey: process.env.ETHERSCAN_API_KEY, apiKey: process.env.ETHERSCAN_API_KEY,
}, },
} }
export default config
...@@ -93,6 +93,10 @@ task('deploy-token', 'Deploy governance token and its mint manager contracts') ...@@ -93,6 +93,10 @@ task('deploy-token', 'Deploy governance token and its mint manager contracts')
console.log(`Got ${tokenReceipt.contractAddress}`) console.log(`Got ${tokenReceipt.contractAddress}`)
throw new Error(`Fatal error! Mismatch of governance token address`) throw new Error(`Fatal error! Mismatch of governance token address`)
} }
} else if (nonceTokenDeployer !== 0 && governanceTokenCode === '0x') {
throw new Error(
`Nonce is ${nonceTokenDeployer} without governance token deployed`
)
} else { } else {
console.log( console.log(
`GovernanceToken already deployed at ${addresses.governanceToken}, skipping` `GovernanceToken already deployed at ${addresses.governanceToken}, skipping`
......
import { task, types } from 'hardhat/config'
import { providers, utils, Wallet } from 'ethers'
import { CrossChainMessenger } from '@eth-optimism/sdk'
import { getChainId } from '@eth-optimism/core-utils'
task('deposit', 'Deposits funds onto Optimism.')
.addParam('to', 'Recipient address.', null, types.string)
.addParam('amountEth', 'Amount in ETH to send.', null, types.string)
.addParam('l1ProviderUrl', '', process.env.L1_PROVIDER_URL, types.string)
.addParam('l2ProviderUrl', '', process.env.L2_PROVIDER_URL, types.string)
.addParam('privateKey', '', process.env.PRIVATE_KEY, types.string)
.setAction(async (args) => {
const { to, amountEth, l1ProviderUrl, l2ProviderUrl, privateKey } = args
if (!l1ProviderUrl || !l2ProviderUrl || !privateKey) {
throw new Error(
'You must define --l1-provider-url, --l2-provider-url, --private-key in your environment.'
)
}
const l1Provider = new providers.JsonRpcProvider(l1ProviderUrl)
const l2Provider = new providers.JsonRpcProvider(l2ProviderUrl)
const l1Wallet = new Wallet(privateKey, l1Provider)
const messenger = new CrossChainMessenger({
l1SignerOrProvider: l1Wallet,
l2SignerOrProvider: l2Provider,
l1ChainId: await getChainId(l1Provider),
l2ChainId: await getChainId(l2Provider),
})
const amountWei = utils.parseEther(amountEth)
console.log(`Depositing ${amountEth} ETH to ${to}...`)
const tx = await messenger.depositETH(amountWei, {
recipient: to,
})
console.log(`Got TX hash ${tx.hash}. Waiting...`)
await tx.wait()
const l1WalletOnL2 = new Wallet(privateKey, l2Provider)
await l1WalletOnL2.sendTransaction({
to,
value: utils.parseEther(amountEth),
})
const balance = await l2Provider.getBalance(to)
console.log('Funded account balance', balance.toString())
console.log('Done.')
})
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment