Commit 591d967a authored by Will Cory's avatar Will Cory

- make deployment scripts a little more typesafe

- add some sanity checks in postDeploymentAction
parent 88dbdffd
...@@ -9,12 +9,16 @@ import { ...@@ -9,12 +9,16 @@ import {
} from '@eth-optimism/contracts-bedrock/src/deploy-utils' } from '@eth-optimism/contracts-bedrock/src/deploy-utils'
import { utils } from 'ethers' import { utils } from 'ethers'
import type { DeployConfig } from '../../src'
const { getAddress } = utils const { getAddress } = utils
/** /**
* Deploys the AttestationStationProxy * Deploys the AttestationStationProxy
*/ */
const deployFn: DeployFunction = async (hre: HardhatRuntimeEnvironment) => { const deployFn: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
const deployConfig = hre.deployConfig as DeployConfig
const { deployer } = await hre.getNamedAccounts() const { deployer } = await hre.getNamedAccounts()
console.log(`Deploying AttestationStationProxy with ${deployer}`) console.log(`Deploying AttestationStationProxy with ${deployer}`)
...@@ -30,6 +34,7 @@ const deployFn: DeployFunction = async (hre: HardhatRuntimeEnvironment) => { ...@@ -30,6 +34,7 @@ const deployFn: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
args: [deployer], args: [deployer],
postDeployAction: async (contract) => { postDeployAction: async (contract) => {
await assertContractVariable(contract, 'admin', deployer) await assertContractVariable(contract, 'admin', deployer)
await assertContractVariable(contract, 'version', '1.0.0')
}, },
}) })
...@@ -62,7 +67,7 @@ const deployFn: DeployFunction = async (hre: HardhatRuntimeEnvironment) => { ...@@ -62,7 +67,7 @@ const deployFn: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
console.log('implementation already set to AttestationStation contract') console.log('implementation already set to AttestationStation contract')
} }
const l2ProxyOwnerAddress = hre.deployConfig.l2ProxyOwnerAddress const l2ProxyOwnerAddress = deployConfig.l2ProxyOwnerAddress
const admin = await Proxy.callStatic.admin() const admin = await Proxy.callStatic.admin()
console.log(`admin is set to ${admin}`) console.log(`admin is set to ${admin}`)
if (getAddress(admin) !== getAddress(l2ProxyOwnerAddress)) { if (getAddress(admin) !== getAddress(l2ProxyOwnerAddress)) {
......
/* Imports: External */ /* Imports: External */
import { DeployFunction } from 'hardhat-deploy/dist/types' import { DeployFunction } from 'hardhat-deploy/dist/types'
import { HardhatRuntimeEnvironment } from 'hardhat/types' import { HardhatRuntimeEnvironment } from 'hardhat/types'
import '@nomiclabs/hardhat-ethers' import '@nomiclabs/hardhat-ethers'
import '@eth-optimism/hardhat-deploy-config' import '@eth-optimism/hardhat-deploy-config'
import 'hardhat-deploy' import 'hardhat-deploy'
import type { DeployConfig } from '../../src'
const deployFn: DeployFunction = async (hre: HardhatRuntimeEnvironment) => { const deployFn: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
const deployConfig = hre.deployConfig as DeployConfig
const { deployer } = await hre.getNamedAccounts() const { deployer } = await hre.getNamedAccounts()
console.log(`Deploying Optimist implementation with ${deployer}`) console.log(`Deploying Optimist implementation with ${deployer}`)
...@@ -16,15 +20,15 @@ const deployFn: DeployFunction = async (hre: HardhatRuntimeEnvironment) => { ...@@ -16,15 +20,15 @@ const deployFn: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
const attestationStationAddress = Deployment__AttestationStation.address const attestationStationAddress = Deployment__AttestationStation.address
console.log(`Using ${attestationStationAddress} as the AttestationStation`) console.log(`Using ${attestationStationAddress} as the AttestationStation`)
console.log(`Using ${hre.deployConfig.attestorAddress} as ATTESTOR`) console.log(`Using ${deployConfig.attestorAddress} as ATTESTOR`)
const { deploy } = await hre.deployments.deterministic('Optimist', { const { deploy } = await hre.deployments.deterministic('Optimist', {
salt: hre.ethers.utils.solidityKeccak256(['string'], ['Optimist']), salt: hre.ethers.utils.solidityKeccak256(['string'], ['Optimist']),
from: deployer, from: deployer,
args: [ args: [
hre.deployConfig.optimistName, deployConfig.optimistName,
hre.deployConfig.optimistSymbol, deployConfig.optimistSymbol,
hre.deployConfig.attestorAddress, deployConfig.attestorAddress,
attestationStationAddress, attestationStationAddress,
], ],
log: true, log: true,
......
...@@ -7,11 +7,15 @@ import 'hardhat-deploy' ...@@ -7,11 +7,15 @@ import 'hardhat-deploy'
import { assertContractVariable } from '@eth-optimism/contracts-bedrock/src/deploy-utils' import { assertContractVariable } from '@eth-optimism/contracts-bedrock/src/deploy-utils'
import { utils } from 'ethers' import { utils } from 'ethers'
import type { DeployConfig } from '../../src'
const { getAddress } = utils const { getAddress } = utils
const deployFn: DeployFunction = async (hre: HardhatRuntimeEnvironment) => { const deployFn: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
const deployConfig = hre.deployConfig as DeployConfig
const { deployer } = await hre.getNamedAccounts() const { deployer } = await hre.getNamedAccounts()
const ddd = hre.deployConfig.ddd const ddd = deployConfig.ddd
if (getAddress(deployer) !== getAddress(ddd)) { if (getAddress(deployer) !== getAddress(ddd)) {
throw new Error('Must deploy with the ddd') throw new Error('Must deploy with the ddd')
...@@ -51,8 +55,8 @@ const deployFn: DeployFunction = async (hre: HardhatRuntimeEnvironment) => { ...@@ -51,8 +55,8 @@ const deployFn: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
console.log(`Setting implementation to ${Deployment__Optimist.address}`) console.log(`Setting implementation to ${Deployment__Optimist.address}`)
// Create the calldata for the call to `initialize()` // Create the calldata for the call to `initialize()`
const name = hre.deployConfig.optimistName const name = deployConfig.optimistName
const symbol = hre.deployConfig.optimistSymbol const symbol = deployConfig.optimistSymbol
const calldata = Optimist.interface.encodeFunctionData('initialize', [ const calldata = Optimist.interface.encodeFunctionData('initialize', [
name, name,
symbol, symbol,
...@@ -68,7 +72,7 @@ const deployFn: DeployFunction = async (hre: HardhatRuntimeEnvironment) => { ...@@ -68,7 +72,7 @@ const deployFn: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
console.log('implementation already set to Optimist contract') console.log('implementation already set to Optimist contract')
} }
const l2ProxyOwnerAddress = hre.deployConfig.l2ProxyOwnerAddress const l2ProxyOwnerAddress = deployConfig.l2ProxyOwnerAddress
const admin = await Proxy.callStatic.admin() const admin = await Proxy.callStatic.admin()
console.log(`admin set to ${admin}`) console.log(`admin set to ${admin}`)
if (getAddress(admin) !== getAddress(l2ProxyOwnerAddress)) { if (getAddress(admin) !== getAddress(l2ProxyOwnerAddress)) {
...@@ -86,15 +90,20 @@ const deployFn: DeployFunction = async (hre: HardhatRuntimeEnvironment) => { ...@@ -86,15 +90,20 @@ const deployFn: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
'AttestationStationProxy' 'AttestationStationProxy'
) )
assertContractVariable(Optimist, 'name', hre.deployConfig.optimistName) await assertContractVariable(Optimist, 'admin', deployer)
assertContractVariable(Optimist, 'symbol', hre.deployConfig.optimistSymbol) await assertContractVariable(Optimist, 'name', deployConfig.optimistName)
assertContractVariable( await assertContractVariable(Optimist, 'verson', '1.0.0')
await assertContractVariable(Optimist, 'symbol', deployConfig.optimistSymbol)
await assertContractVariable(
Optimist,
'ATTESTOR',
deployConfig.attestorAddress
)
await assertContractVariable(
Optimist, Optimist,
'ATTESTATION_STATION', 'ATTESTATION_STATION',
Deployment__AttestationStation.address Deployment__AttestationStation.address
) )
assertContractVariable(Optimist, 'ATTESTOR', hre.deployConfig.attestorAddress)
assertContractVariable(Optimist, 'version', '0.0.1')
} }
deployFn.tags = ['OptimistProxy'] deployFn.tags = ['OptimistProxy']
......
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