Commit 746ce554 authored by Will Cory's avatar Will Cory Committed by Mark Tyneway

ctp: add deploy script for optimist sbt

Run with the following command:

```bash
npx hardhat deploy --tags OptimistProxy --network hardhat
```
parent 5be495e0
---
'@eth-optimism/contracts-periphery': patch
---
Add deployment scripts for optimist
......@@ -3,6 +3,9 @@ import { DeployConfig } from '../../src'
const config: DeployConfig = {
ddd: '0x9C6373dE60c2D3297b18A8f964618ac46E011B58',
l2ProxyOwnerAddress: '',
optimistName: '',
optimistSymbol: '',
attestorAddress: '',
}
export default config
......@@ -3,6 +3,9 @@ import { DeployConfig } from '../../src'
const config: DeployConfig = {
ddd: '0x9C6373dE60c2D3297b18A8f964618ac46E011B58',
l2ProxyOwnerAddress: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
optimistName: 'OP Citizenship',
optimistSymbol: 'OPNFT',
attestorAddress: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
}
export default config
......@@ -4,6 +4,9 @@ import { DeployConfig } from '../../src'
const config: DeployConfig = {
ddd: '0x9C6373dE60c2D3297b18A8f964618ac46E011B58',
l2ProxyOwnerAddress: '',
optimistName: '',
optimistSymbol: '',
attestorAddress: '',
}
export default config
......@@ -3,6 +3,9 @@ import { DeployConfig } from '../../src'
const config: DeployConfig = {
ddd: '0x9C6373dE60c2D3297b18A8f964618ac46E011B58',
l2ProxyOwnerAddress: '',
optimistName: '',
optimistSymbol: '',
attestorAddress: '',
}
export default config
......@@ -3,6 +3,9 @@ import { DeployConfig } from '../../src'
const config: DeployConfig = {
ddd: '0x9C6373dE60c2D3297b18A8f964618ac46E011B58',
l2ProxyOwnerAddress: '',
optimistName: '',
optimistSymbol: '',
attestorAddress: '',
}
export default config
import { DeployConfig } from '../../src'
// TODO(tynes): optimism-kovan is deprecated, delete this file
const config: DeployConfig = {
ddd: '0x9C6373dE60c2D3297b18A8f964618ac46E011B58',
l2ProxyOwnerAddress: '',
optimistName: '',
optimistSymbol: '',
attestorAddress: '',
}
export default config
/* Imports: External */
import { DeployFunction } from 'hardhat-deploy/dist/types'
import { HardhatRuntimeEnvironment } from 'hardhat/types'
import '@nomiclabs/hardhat-ethers'
import '@eth-optimism/hardhat-deploy-config'
import 'hardhat-deploy'
const deployFn: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
const { deployer } = await hre.getNamedAccounts()
console.log(`Deploying Optimist implementation with ${deployer}`)
const Deployment__AttestationStation = await hre.deployments.get(
'AttestationStationProxy'
)
const attestationStationAddress = Deployment__AttestationStation.address
console.log(`Using ${attestationStationAddress} as the AttestationStation`)
console.log(`Using ${hre.deployConfig.attestorAddress} as ATTESTOR`)
const { deploy } = await hre.deployments.deterministic('Optimist', {
salt: hre.ethers.utils.solidityKeccak256(['string'], ['Optimist']),
from: deployer,
args: [
hre.deployConfig.optimistName,
hre.deployConfig.optimistSymbol,
hre.deployConfig.attestorAddress,
attestationStationAddress,
],
log: true,
})
await deploy()
}
deployFn.tags = ['Optimist', 'OptimistEnvironment']
export default deployFn
/* Imports: External */
import { DeployFunction } from 'hardhat-deploy/dist/types'
import { HardhatRuntimeEnvironment } from 'hardhat/types'
import '@eth-optimism/hardhat-deploy-config'
import '@nomiclabs/hardhat-ethers'
import 'hardhat-deploy'
import {
assertContractVariable,
deploy,
} from '@eth-optimism/contracts-bedrock/src/deploy-utils'
import { utils } from 'ethers'
const { getAddress } = utils
const deployFn: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
const { deployer } = await hre.getNamedAccounts()
const Deployment__Optimist = await hre.deployments.get('Optimist')
console.log(`Deploying OptimistProxy with ${deployer}`)
await deploy({
hre,
name: 'OptimistProxy',
contract: 'Proxy',
args: [deployer],
postDeployAction: async (contract) => {
await assertContractVariable(contract, 'admin', deployer)
},
})
const Deployment__OptimistProxy = await hre.deployments.get('OptimistProxy')
console.log(`OptimistProxy deployed to ${Deployment__OptimistProxy.address}`)
const Proxy = await hre.ethers.getContractAt(
'Proxy',
Deployment__OptimistProxy.address
)
const Optimist = await hre.ethers.getContractAt(
'Optimist',
Deployment__OptimistProxy.address
)
const implementation = await Proxy.callStatic.implementation()
console.log(`implementation set to ${implementation}`)
if (getAddress(implementation) !== getAddress(Deployment__Optimist.address)) {
console.log('implementation not set to Optimist contract')
console.log(`Setting implementation to ${Deployment__Optimist.address}`)
// Create the calldata for the call to `initialize()`
const name = hre.deployConfig.optimistName
const symbol = hre.deployConfig.optimistSymbol
const calldata = Optimist.interface.encodeFunctionData('initialize', [
name,
symbol,
])
const tx = await Proxy.upgradeToAndCall(
Deployment__Optimist.address,
calldata
)
const receipt = await tx.wait()
console.log(`implementation set in ${receipt.transactionHash}`)
} else {
console.log('implementation already set to Optimist contract')
}
const l2ProxyOwnerAddress = hre.deployConfig.l2ProxyOwnerAddress
const admin = await Proxy.callStatic.admin()
console.log(`admin set to ${admin}`)
if (getAddress(admin) !== getAddress(l2ProxyOwnerAddress)) {
console.log('detected admin is not set')
console.log(`Setting admin to ${l2ProxyOwnerAddress}`)
const tx = await Proxy.changeAdmin(l2ProxyOwnerAddress)
const receipt = await tx.wait()
console.log(`admin set in ${receipt.transactionHash}`)
} else {
console.log('admin already set to proxy owner address')
}
}
deployFn.tags = ['OptimistProxy']
deployFn.dependencies = ['AttestationStationProxy', 'Optimist']
export default deployFn
......@@ -14,14 +14,31 @@ export interface DeployConfig {
ddd: string
/**
* Address of the Proxy owner on L2
* Number of confs before considering it final
*/
l2ProxyOwnerAddress: string
numDeployConfirmations?: number
/**
* Number of confs before considering it final
* Name of the NFT in the Optimist contract.
*/
numDeployConfirmations?: number
optimistName: string
/**
* Symbol of the NFT in the Optimist contract.
*/
optimistSymbol: string
/**
* Address of the priviledged attestor for the Optimist contract.
*/
attestorAddress: string
/**
* Address of the owner of the proxies on L2. There will be a ProxyAdmin deployed as a predeploy
* after bedrock, so the owner of proxies should be updated to that after the upgrade.
* This currently is used as the owner of the nft related proxies.
*/
l2ProxyOwnerAddress: string
}
/**
......@@ -31,11 +48,20 @@ export const configSpec: DeployConfigSpec<DeployConfig> = {
ddd: {
type: 'address',
},
l2ProxyOwnerAddress: {
type: 'address',
},
numDeployConfirmations: {
type: 'number',
default: 1,
},
optimistName: {
type: 'string',
},
optimistSymbol: {
type: 'string',
},
attestorAddress: {
type: 'address',
},
l2ProxyOwnerAddress: {
type: 'address',
},
}
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