-
Notifications
You must be signed in to change notification settings - Fork 3.9k
ctp: fixup deploy scripts for the nft bridge #3570
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
45914f6
ctp: fixup deploy scripts for the nft bridge
tynes b9959f0
ctp: update deploy scripts
tynes f8f8c55
ctp: update deploy scripts
tynes f61aca8
ctp: move away from deterministic deployments
tynes ea330c3
op: deployments
tynes 541f5aa
fixes
tynes 0bda78b
deploy-script: refactor
tynes 501a280
deploy: comments
tynes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
102 changes: 99 additions & 3 deletions
102
packages/contracts-periphery/deploy/nft-bridge/L1ERC721BridgeImplementation.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 27 additions & 14 deletions
41
packages/contracts-periphery/deploy/nft-bridge/L1ERC721BridgeProxy.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 80 additions & 3 deletions
83
packages/contracts-periphery/deploy/nft-bridge/L2ERC721BridgeImplementation.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,18 +1,95 @@ | ||
| /* Imports: External */ | ||
| import { DeployFunction } from 'hardhat-deploy/dist/types' | ||
| import { ethers } from 'hardhat' | ||
| import '@eth-optimism/hardhat-deploy-config' | ||
| import '@nomiclabs/hardhat-ethers' | ||
| import 'hardhat-deploy' | ||
| import { predeploys } from '@eth-optimism/contracts' | ||
|
|
||
| import { | ||
| isTargetL2Network, | ||
| predeploy, | ||
| validateERC721Bridge, | ||
| getProxyAdmin, | ||
| } from '../../src/nft-bridge-deploy-helpers' | ||
|
|
||
| const deployFn: DeployFunction = async (hre) => { | ||
| const { deployer } = await hre.getNamedAccounts() | ||
| const { getAddress } = hre.ethers.utils | ||
|
|
||
| if (!isTargetL2Network(hre.network.name)) { | ||
| console.log(`Deploying to unsupported network ${hre.network.name}`) | ||
| return | ||
| } | ||
|
|
||
| console.log(`Deploying L2ERC721Bridge to ${hre.network.name}`) | ||
| console.log(`Using deployer ${deployer}`) | ||
|
|
||
| const L2ERC721BridgeProxy = await hre.ethers.getContractAt('Proxy', predeploy) | ||
|
|
||
| // Check to make sure that the admin of the proxy is the deployer. | ||
| // The deployer of the L2ERC721Bridge should be the same as the | ||
| // admin of the L2ERC721BridgeProxy so that it is easy to upgrade | ||
| // the implementation. The admin is then changed depending on the | ||
| // network after the L2ERC721BridgeProxy is upgraded to the implementation | ||
| const admin = await L2ERC721BridgeProxy.callStatic.admin() | ||
tynes marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| if (getAddress(admin) !== getAddress(deployer)) { | ||
| throw new Error(`Unexpected admin ${admin}`) | ||
| } | ||
|
|
||
| const Deployment__L1ERC721Bridge = await hre.deployments.get( | ||
| 'L1ERC721BridgeProxy' | ||
| ) | ||
|
|
||
| const L1ERC721BridgeAddress = Deployment__L1ERC721Bridge.address | ||
|
|
||
| // Deploy the L2ERC721Bridge implementation | ||
| await hre.deployments.deploy('L2ERC721Bridge', { | ||
| from: deployer, | ||
| args: [ethers.constants.AddressZero, ethers.constants.AddressZero], | ||
| args: [predeploys.L2CrossDomainMessenger, L1ERC721BridgeAddress], | ||
| log: true, | ||
| waitConfirmations: 1, | ||
| }) | ||
|
|
||
| const Deployment__L2ERC721Bridge = await hre.deployments.get('L2ERC721Bridge') | ||
| console.log( | ||
| `L2ERC721Bridge deployed to ${Deployment__L2ERC721Bridge.address}` | ||
| ) | ||
|
|
||
| await validateERC721Bridge(hre, Deployment__L2ERC721Bridge.address, { | ||
| messenger: predeploys.L2CrossDomainMessenger, | ||
| otherBridge: L1ERC721BridgeAddress, | ||
| }) | ||
|
|
||
| { | ||
| // Upgrade the implementation of the proxy to the newly deployed | ||
| // L2ERC721Bridge | ||
| const tx = await L2ERC721BridgeProxy.upgradeTo( | ||
| Deployment__L2ERC721Bridge.address | ||
| ) | ||
| const receipt = await tx.wait() | ||
| console.log( | ||
| `Upgraded the implementation of the L2ERC721BridgeProxy: ${receipt.transactionhash}` | ||
| ) | ||
| } | ||
tynes marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| await validateERC721Bridge(hre, L2ERC721BridgeProxy.address, { | ||
| messenger: predeploys.L2CrossDomainMessenger, | ||
| otherBridge: L1ERC721BridgeAddress, | ||
| }) | ||
|
|
||
| { | ||
| const newAdmin = getProxyAdmin(hre.network.name) | ||
| console.log(`Changing admin to ${newAdmin}`) | ||
tynes marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| const tx = await L2ERC721BridgeProxy.changeAdmin(newAdmin) | ||
| const receipt = await tx.wait() | ||
| console.log( | ||
| `Changed admin of the L2ERC721BridgeProxy: ${receipt.transactionHash}` | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| deployFn.tags = ['L2ERC721BridgeImplementation'] | ||
| deployFn.dependencies = ['L2ERC721BridgeProxy'] | ||
| deployFn.dependencies = ['L2ERC721BridgeProxy', 'L1ERC721BridgeProxy'] | ||
|
|
||
| export default deployFn | ||
70 changes: 57 additions & 13 deletions
70
packages/contracts-periphery/deploy/nft-bridge/L2ERC721BridgeProxy.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.