Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
e93ee9ec
Unverified
Commit
e93ee9ec
authored
Oct 22, 2021
by
Maurelian
Committed by
Kelvin Fichter
Nov 10, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor(Contracts): combine getReusableContract and getDeployedContract into getLiveContract
parent
75b1e727
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
49 additions
and
56 deletions
+49
-56
deploy.ts
packages/contracts/bin/deploy.ts
+1
-1
010-OVM_ChainStorageContainer_ctc_batches.deploy.ts
...eploy/010-OVM_ChainStorageContainer_ctc_batches.deploy.ts
+2
-6
020-OVM_ChainStorageContainer_scc_batches.deploy.ts
...eploy/020-OVM_ChainStorageContainer_scc_batches.deploy.ts
+2
-6
030-OVM_CanonicalTransactionChain.deploy.ts
...tracts/deploy/030-OVM_CanonicalTransactionChain.deploy.ts
+2
-6
040-OVM_StateCommitmentChain.deploy.ts
...s/contracts/deploy/040-OVM_StateCommitmentChain.deploy.ts
+2
-6
050-OVM_BondManager.deploy.ts
packages/contracts/deploy/050-OVM_BondManager.deploy.ts
+2
-6
060-OVM_L1CrossDomainMessenger.deploy.ts
...contracts/deploy/060-OVM_L1CrossDomainMessenger.deploy.ts
+2
-2
070-Proxy__OVM_L1CrossDomainMessenger.deploy.ts
...ts/deploy/070-Proxy__OVM_L1CrossDomainMessenger.deploy.ts
+2
-5
110-AddressSetter.deploy.ts
packages/contracts/deploy/110-AddressSetter.deploy.ts
+3
-7
120-initialize-Proxy__L1CrossDomainMessenger.ts
...ts/deploy/120-initialize-Proxy__L1CrossDomainMessenger.ts
+10
-7
hardhat-deploy-ethers.ts
packages/contracts/src/hardhat-deploy-ethers.ts
+21
-4
No files found.
packages/contracts/bin/deploy.ts
View file @
e93ee9ec
...
...
@@ -67,7 +67,7 @@ const main = async () => {
ovmAddressManagerOwner
:
deployer
.
address
,
numDeployConfirmations
:
0
,
noCompile
:
process
.
env
.
NO_COMPILE
?
true
:
false
,
tags
:
'
upgrade,Lib_AddressManager,Proxy__L1CrossDomainMessenger,Proxy__L1StandardBridge,deployer-set-addresses
'
,
tags
:
'
fresh
'
,
})
// Stuff below this line is currently required for CI to work properly. We probably want to
...
...
packages/contracts/deploy/010-OVM_ChainStorageContainer_ctc_batches.deploy.ts
View file @
e93ee9ec
...
...
@@ -4,15 +4,11 @@ import { DeployFunction } from 'hardhat-deploy/dist/types'
/* Imports: Internal */
import
{
deployAndPostDeploy
,
getDeployedContract
,
getReusableContract
,
getLiveContract
,
}
from
'
../src/hardhat-deploy-ethers
'
const
deployFn
:
DeployFunction
=
async
(
hre
)
=>
{
const
Lib_AddressManager
=
await
getReusableContract
(
hre
,
'
Lib_AddressManager
'
)
const
Lib_AddressManager
=
await
getLiveContract
(
hre
,
'
Lib_AddressManager
'
)
await
deployAndPostDeploy
({
hre
,
...
...
packages/contracts/deploy/020-OVM_ChainStorageContainer_scc_batches.deploy.ts
View file @
e93ee9ec
...
...
@@ -4,15 +4,11 @@ import { DeployFunction } from 'hardhat-deploy/dist/types'
/* Imports: Internal */
import
{
deployAndPostDeploy
,
getDeployedContract
,
getReusableContract
,
getLiveContract
,
}
from
'
../src/hardhat-deploy-ethers
'
const
deployFn
:
DeployFunction
=
async
(
hre
)
=>
{
const
Lib_AddressManager
=
await
getReusableContract
(
hre
,
'
Lib_AddressManager
'
)
const
Lib_AddressManager
=
await
getLiveContract
(
hre
,
'
Lib_AddressManager
'
)
await
deployAndPostDeploy
({
hre
,
...
...
packages/contracts/deploy/030-OVM_CanonicalTransactionChain.deploy.ts
View file @
e93ee9ec
...
...
@@ -4,15 +4,11 @@ import { DeployFunction } from 'hardhat-deploy/dist/types'
/* Imports: Internal */
import
{
deployAndPostDeploy
,
getDeployedContract
,
getReusableContract
,
getLiveContract
,
}
from
'
../src/hardhat-deploy-ethers
'
const
deployFn
:
DeployFunction
=
async
(
hre
)
=>
{
const
Lib_AddressManager
=
await
getReusableContract
(
hre
,
'
Lib_AddressManager
'
)
const
Lib_AddressManager
=
await
getLiveContract
(
hre
,
'
Lib_AddressManager
'
)
await
deployAndPostDeploy
({
hre
,
...
...
packages/contracts/deploy/040-OVM_StateCommitmentChain.deploy.ts
View file @
e93ee9ec
...
...
@@ -4,15 +4,11 @@ import { DeployFunction } from 'hardhat-deploy/dist/types'
/* Imports: Internal */
import
{
deployAndPostDeploy
,
getDeployedContract
,
getReusableContract
,
getLiveContract
,
}
from
'
../src/hardhat-deploy-ethers
'
const
deployFn
:
DeployFunction
=
async
(
hre
)
=>
{
const
Lib_AddressManager
=
await
getReusableContract
(
hre
,
'
Lib_AddressManager
'
)
const
Lib_AddressManager
=
await
getLiveContract
(
hre
,
'
Lib_AddressManager
'
)
await
deployAndPostDeploy
({
hre
,
...
...
packages/contracts/deploy/050-OVM_BondManager.deploy.ts
View file @
e93ee9ec
...
...
@@ -4,15 +4,11 @@ import { DeployFunction } from 'hardhat-deploy/dist/types'
/* Imports: Internal */
import
{
deployAndPostDeploy
,
getDeployedContract
,
getReusableContract
,
getLiveContract
,
}
from
'
../src/hardhat-deploy-ethers
'
const
deployFn
:
DeployFunction
=
async
(
hre
)
=>
{
const
Lib_AddressManager
=
await
getReusableContract
(
hre
,
'
Lib_AddressManager
'
)
const
Lib_AddressManager
=
await
getLiveContract
(
hre
,
'
Lib_AddressManager
'
)
await
deployAndPostDeploy
({
hre
,
...
...
packages/contracts/deploy/060-OVM_L1CrossDomainMessenger.deploy.ts
View file @
e93ee9ec
...
...
@@ -5,12 +5,12 @@ import { hexStringEquals } from '@eth-optimism/core-utils'
/* Imports: Internal */
import
{
deployAndPostDeploy
,
get
Reusabl
eContract
,
get
Liv
eContract
,
waitUntilTrue
,
}
from
'
../src/hardhat-deploy-ethers
'
const
deployFn
:
DeployFunction
=
async
(
hre
)
=>
{
const
Lib_AddressManager
=
await
get
Reusabl
eContract
(
const
Lib_AddressManager
=
await
get
Liv
eContract
(
hre
,
'
Lib_AddressManager
'
)
...
...
packages/contracts/deploy/070-Proxy__OVM_L1CrossDomainMessenger.deploy.ts
View file @
e93ee9ec
...
...
@@ -5,15 +5,12 @@ import { hexStringEquals } from '@eth-optimism/core-utils'
/* Imports: Internal */
import
{
deployAndPostDeploy
,
get
Reusabl
eContract
,
get
Liv
eContract
,
waitUntilTrue
,
}
from
'
../src/hardhat-deploy-ethers
'
const
deployFn
:
DeployFunction
=
async
(
hre
)
=>
{
const
Lib_AddressManager
=
await
getReusableContract
(
hre
,
'
Lib_AddressManager
'
)
const
Lib_AddressManager
=
await
getLiveContract
(
hre
,
'
Lib_AddressManager
'
)
// todo: this fails when trying to do a fresh deploy, because Lib_ResolvedDelegateProxy
// requires that the implementation has already been set in the Address Manager.
...
...
packages/contracts/deploy/110-AddressSetter.deploy.ts
View file @
e93ee9ec
...
...
@@ -4,16 +4,12 @@ import { DeployFunction } from 'hardhat-deploy/dist/types'
/* Imports: Internal */
import
{
deployAndPostDeploy
,
getDeployedContract
,
getReusableContract
,
getLiveContract
,
}
from
'
../src/hardhat-deploy-ethers
'
import
{
predeploys
}
from
'
../src/predeploys
'
const
deployFn
:
DeployFunction
=
async
(
hre
)
=>
{
const
Lib_AddressManager
=
await
getReusableContract
(
hre
,
'
Lib_AddressManager
'
)
const
Lib_AddressManager
=
await
getLiveContract
(
hre
,
'
Lib_AddressManager
'
)
// ToDo: Clean up the method of mapping names to addresses esp.
// There's probably a more functional way to generate an object or something.
...
...
@@ -31,7 +27,7 @@ const deployFn: DeployFunction = async (hre) => {
const
addresses
=
await
Promise
.
all
(
names
.
map
(
async
(
n
)
=>
{
return
(
await
get
Deployed
Contract
(
hre
,
n
)).
address
return
(
await
get
Live
Contract
(
hre
,
n
)).
address
})
)
...
...
packages/contracts/deploy/120-initialize-Proxy__L1CrossDomainMessenger.ts
View file @
e93ee9ec
...
...
@@ -3,23 +3,26 @@ import { DeployFunction } from 'hardhat-deploy/dist/types'
import
{
hexStringEquals
}
from
'
@eth-optimism/core-utils
'
/* Imports: Internal */
import
{
getLiveContract
,
waitUntilTrue
,
}
from
'
../src/hardhat-deploy-ethers
'
import
{
getLiveContract
,
waitUntilTrue
}
from
'
../src/hardhat-deploy-ethers
'
const
deployFn
:
DeployFunction
=
async
(
hre
)
=>
{
const
{
deployer
}
=
await
hre
.
getNamedAccounts
()
// There is a risk that on a fresh deployment we could get front-run,
// and the Proxy would be bricked. But that feels unlikely, and we can recover from it.
console
.
log
(
`Initializing Proxy__L1CrossDomainMessenger...`
)
const
proxy
=
getLiveContract
(
'
Proxy__L1CrossDomainMessenger
'
)
await
proxy
.
initialize
(
Lib_AddressManager
.
address
)
const
proxy
=
await
getLiveContract
(
hre
,
'
Proxy__L1CrossDomainMessenger
'
,
{
iface
:
'
L1CrossDomainMessenger
'
,
signerOrProvider
:
deployer
,
})
const
libAddressManager
=
await
getLiveContract
(
hre
,
'
Lib_AddressManager
'
)
await
proxy
.
initialize
(
libAddressManager
.
address
)
console
.
log
(
`Checking that contract was correctly initialized...`
)
await
waitUntilTrue
(
async
()
=>
{
return
hexStringEquals
(
await
proxy
.
libAddressManager
(),
Lib_
AddressManager
.
address
lib
AddressManager
.
address
)
})
}
...
...
packages/contracts/src/hardhat-deploy-ethers.ts
View file @
e93ee9ec
...
...
@@ -136,7 +136,14 @@ export const getAdvancedContract = (opts: {
return
contract
}
export
const
getDeployedContract
=
async
(
// A map from contract names to config names which can be passed as arguments to hardhat deploy
const
configNames
=
{
Lib_AddressManager
:
'
libAddressManager
'
,
Proxy__L1CrossDomainMessenger
:
'
proxyL1CrossDomainMessenger
'
,
Proxy__L1StandardBridge
:
'
proxyL1StandardBridge
'
,
}
export
const
getLiveContract
=
async
(
hre
:
any
,
name
:
string
,
options
:
{
...
...
@@ -144,14 +151,24 @@ export const getDeployedContract = async (
signerOrProvider
?:
Signer
|
Provider
|
string
}
=
{}
):
Promise
<
Contract
>
=>
{
const
deployed
=
await
hre
.
deployments
.
get
(
name
)
let
factory
=
await
hre
.
ethers
.
getContractFactory
(
name
)
let
iface
=
factory
.
interface
// First check to see if the contract is being reused in an upgrade, rather than freshly deployed.
// If so, then a valid address would have been provided for one of the 3 contracts in configNames.
const
addr
=
(
hre
as
any
).
deployConfig
[
configNames
[
name
]]
if
(
hre
.
ethers
.
utils
.
isAddress
(
addr
))
{
return
new
Contract
(
addr
,
iface
)
}
// Otherwise, look for a previously deployed contract
const
deployed
=
await
hre
.
deployments
.
get
(
name
)
await
hre
.
ethers
.
provider
.
waitForTransaction
(
deployed
.
receipt
.
transactionHash
)
// Get the correct interface.
let
iface
=
new
hre
.
ethers
.
utils
.
Interface
(
deployed
.
abi
)
iface
=
new
hre
.
ethers
.
utils
.
Interface
(
deployed
.
abi
)
if
(
options
.
iface
)
{
const
factory
=
await
hre
.
ethers
.
getContractFactory
(
options
.
iface
)
factory
=
await
hre
.
ethers
.
getContractFactory
(
options
.
iface
)
iface
=
factory
.
interface
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment