Skip to content

Commit

Permalink
feat(ctp): add deploy configuration for NFT bridge (#2780)
Browse files Browse the repository at this point in the history
* contracts: deploy scripts

* deploy-scripts: rename

* wip: deploy script

* feat: use deploy config plugin

Co-authored-by: Mark Tyneway <mark.tyneway@gmail.com>
  • Loading branch information
smartcontracts and tynes committed Jun 15, 2022
1 parent ff0723a commit a320e74
Show file tree
Hide file tree
Showing 21 changed files with 185 additions and 179 deletions.
5 changes: 5 additions & 0 deletions .changeset/eleven-pears-develop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@eth-optimism/hardhat-deploy-config': patch
---

Properly exports DeployConfigSpec type
5 changes: 5 additions & 0 deletions .changeset/late-singers-roll.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@eth-optimism/contracts-periphery': patch
---

Updates contracts-periphery to use the standardized hardhat deploy config plugin
7 changes: 7 additions & 0 deletions packages/contracts-periphery/config/deploy/hardhat.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { DeployConfig } from '../../src'

const config: DeployConfig = {
ddd: '0x9C6373dE60c2D3297b18A8f964618ac46E011B58',
}

export default config
22 changes: 22 additions & 0 deletions packages/contracts-periphery/deploy/PeripheryProxyAdmin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/* Imports: External */
import { DeployFunction } from 'hardhat-deploy/dist/types'

const deployFn: DeployFunction = async (hre) => {
const { deployer } = await hre.getNamedAccounts()

const { deploy } = await hre.deployments.deterministic('ProxyAdmin', {
salt: hre.ethers.utils.solidityKeccak256(
['string'],
['PeripheryProxyAdmin']
),
from: deployer,
args: [hre.deployConfig.ddd],
log: true,
})

await deploy()
}

deployFn.tags = ['PeripheryProxyAdmin']

export default deployFn
6 changes: 1 addition & 5 deletions packages/contracts-periphery/deploy/RetroReceiver.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
/* Imports: External */
import { DeployFunction } from 'hardhat-deploy/dist/types'

import { getDeployConfig } from '../src'

const deployFn: DeployFunction = async (hre) => {
const { deployer } = await hre.getNamedAccounts()

const config = getDeployConfig(hre.network.name)

const { deploy } = await hre.deployments.deterministic('AssetReceiver', {
salt: hre.ethers.utils.solidityKeccak256(['string'], ['RetroReceiver']),
from: deployer,
args: [config.ddd],
args: [hre.deployConfig.ddd],
log: true,
})

Expand Down
6 changes: 1 addition & 5 deletions packages/contracts-periphery/deploy/TeleportrWithdrawer.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
/* Imports: External */
import { DeployFunction } from 'hardhat-deploy/dist/types'

import { getDeployConfig } from '../src'

const deployFn: DeployFunction = async (hre) => {
const { deployer } = await hre.getNamedAccounts()

const config = getDeployConfig(hre.network.name)

const { deploy } = await hre.deployments.deterministic(
'TeleportrWithdrawer',
{
Expand All @@ -16,7 +12,7 @@ const deployFn: DeployFunction = async (hre) => {
['TeleportrWithdrawer']
),
from: deployer,
args: [config.ddd],
args: [hre.deployConfig.ddd],
log: true,
}
)
Expand Down
6 changes: 1 addition & 5 deletions packages/contracts-periphery/deploy/drippie/Drippie.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
/* Imports: External */
import { DeployFunction } from 'hardhat-deploy/dist/types'

import { getDeployConfig } from '../../src'

const deployFn: DeployFunction = async (hre) => {
const { deployer } = await hre.getNamedAccounts()

const config = getDeployConfig(hre.network.name)

const { deploy } = await hre.deployments.deterministic('Drippie', {
salt: hre.ethers.utils.solidityKeccak256(['string'], ['Drippie']),
from: deployer,
args: [config.ddd],
args: [hre.deployConfig.ddd],
log: true,
})

Expand Down
22 changes: 0 additions & 22 deletions packages/contracts-periphery/deploy/nft-bridge/L1ERC721Bridge.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
/* Imports: External */
import { DeployFunction } from 'hardhat-deploy/dist/types'
import { ethers } from 'hardhat'

const deployFn: DeployFunction = async (hre) => {
const { deployer } = await hre.getNamedAccounts()
const L2ERC721Bridge = await hre.deployments.get('L2ERC721Bridge')

await hre.deployments.deploy('L2StandardERC721Factory', {
await hre.deployments.deploy('L1ERC721Bridge', {
from: deployer,
args: [L2ERC721Bridge.address],
args: [ethers.constants.AddressZero, ethers.constants.AddressZero],
log: true,
})
}

deployFn.tags = ['L2StandardERC721Factory']
deployFn.tags = ['L1ERC721BridgeImplementation']
deployFn.dependencies = ['L1ERC721BridgeProxy']

export default deployFn
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/* Imports: External */
import { DeployFunction } from 'hardhat-deploy/dist/types'

const deployFn: DeployFunction = async (hre) => {
const { deployer } = await hre.getNamedAccounts()

const { deploy } = await hre.deployments.deterministic('Proxy', {
salt: hre.ethers.utils.solidityKeccak256(
['string'],
['L1ERC721BridgeProxy']
),
from: deployer,
args: [hre.deployConfig.ddd],
log: true,
})

await deploy()
}

deployFn.tags = ['L1ERC721BridgeProxy']

export default deployFn
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
/* Imports: External */
import { DeployFunction } from 'hardhat-deploy/dist/types'
import { predeploys } from '@eth-optimism/contracts'
import { ethers } from 'hardhat'

const deployFn: DeployFunction = async (hre) => {
const { deployer } = await hre.getNamedAccounts()

await hre.deployments.deploy('L2ERC721Bridge', {
from: deployer,
args: [predeploys.L2CrossDomainMessenger],
args: [ethers.constants.AddressZero, ethers.constants.AddressZero],
log: true,
})
}

deployFn.tags = ['L2ERC721Bridge']
deployFn.tags = ['L2ERC721BridgeImplementation']
deployFn.dependencies = ['L2ERC721BridgeProxy']

export default deployFn
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/* Imports: External */
import { DeployFunction } from 'hardhat-deploy/dist/types'

const deployFn: DeployFunction = async (hre) => {
const { deployer } = await hre.getNamedAccounts()

const { deploy } = await hre.deployments.deterministic('Proxy', {
salt: hre.ethers.utils.solidityKeccak256(
['string'],
['L2ERC721BridgeProxy']
),
from: deployer,
args: [hre.deployConfig.ddd],
log: true,
})

await deploy()
}

deployFn.tags = ['L2ERC721BridgeProxy']

export default deployFn
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/* Imports: External */
import { DeployFunction } from 'hardhat-deploy/dist/types'
import { ethers } from 'hardhat'

const deployFn: DeployFunction = async (hre) => {
const { deployer } = await hre.getNamedAccounts()

await hre.deployments.deploy('OptimismMintableERC721Factory', {
from: deployer,
args: [ethers.constants.AddressZero],
log: true,
})
}

deployFn.tags = ['OptimismMintableERC721FactoryImplementation']
deployFn.dependencies = ['OptimismMintableERC721FactoryProxy']

export default deployFn
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/* Imports: External */
import { DeployFunction } from 'hardhat-deploy/dist/types'

const deployFn: DeployFunction = async (hre) => {
const { deployer } = await hre.getNamedAccounts()

const { deploy } = await hre.deployments.deterministic('Proxy', {
salt: hre.ethers.utils.solidityKeccak256(
['string'],
['OptimismMintableERC721FactoryProxy']
),
from: deployer,
args: [hre.deployConfig.ddd],
log: true,
})

await deploy()
}

deployFn.tags = ['OptimismMintableERC721FactoryProxy']

export default deployFn

This file was deleted.

26 changes: 14 additions & 12 deletions packages/contracts-periphery/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@ import { HardhatUserConfig } from 'hardhat/types'
import { getenv } from '@eth-optimism/core-utils'
import * as dotenv from 'dotenv'

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

// Hardhat plugins
import '@nomiclabs/hardhat-ethers'
import '@nomiclabs/hardhat-waffle'
import '@nomiclabs/hardhat-etherscan'
import '@eth-optimism/hardhat-deploy-config'
import 'solidity-coverage'
import 'hardhat-gas-reporter'
import 'hardhat-deploy'
Expand All @@ -21,9 +24,6 @@ const config: HardhatUserConfig = {
optimism: {
chainId: 10,
url: 'https://mainnet.optimism.io',
companionNetworks: {
l1: 'mainnet',
},
verify: {
etherscan: {
apiKey: getenv('OPTIMISTIC_ETHERSCAN_API_KEY'),
Expand All @@ -33,9 +33,6 @@ const config: HardhatUserConfig = {
'optimism-kovan': {
chainId: 69,
url: 'https://kovan.optimism.io',
companionNetworks: {
l1: 'kovan',
},
verify: {
etherscan: {
apiKey: getenv('OPTIMISTIC_ETHERSCAN_API_KEY'),
Expand All @@ -45,9 +42,6 @@ const config: HardhatUserConfig = {
ethereum: {
chainId: 1,
url: `https://mainnet.infura.io/v3/${getenv('INFURA_PROJECT_ID')}`,
companionNetworks: {
l2: 'optimism',
},
verify: {
etherscan: {
apiKey: getenv('ETHEREUM_ETHERSCAN_API_KEY'),
Expand Down Expand Up @@ -75,16 +69,24 @@ const config: HardhatUserConfig = {
kovan: {
chainId: 42,
url: `https://kovan.infura.io/v3/${getenv('INFURA_PROJECT_ID')}`,
companionNetworks: {
l2: 'optimism-kovan',
},
verify: {
etherscan: {
apiKey: getenv('ETHEREUM_ETHERSCAN_API_KEY'),
},
},
},
},
paths: {
deployConfig: './config/deploy',
},
deployConfigSpec: configSpec,
external: {
contracts: [
{
artifacts: '../contracts-bedrock/artifacts',
},
],
},
mocha: {
timeout: 50000,
},
Expand Down
3 changes: 2 additions & 1 deletion packages/contracts-periphery/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,14 @@
"@defi-wonderland/smock": "^2.0.7",
"@eth-optimism/contracts": "^0.5.26",
"@eth-optimism/core-utils": "^0.8.6",
"@eth-optimism/hardhat-deploy-config": "^0.1.0",
"@ethersproject/hardware-wallets": "^5.6.1",
"@nomiclabs/hardhat-ethers": "^2.0.2",
"@nomiclabs/hardhat-etherscan": "^3.0.3",
"@nomiclabs/hardhat-waffle": "^2.0.1",
"@rari-capital/solmate": "^6.3.0",
"@openzeppelin/contracts": "4.6.0",
"@openzeppelin/contracts-upgradeable": "4.6.0",
"@rari-capital/solmate": "^6.3.0",
"@types/chai": "^4.2.18",
"@types/mocha": "^8.2.2",
"@types/node": "^17.0.21",
Expand Down

0 comments on commit a320e74

Please sign in to comment.