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
b3b97959
Unverified
Commit
b3b97959
authored
Oct 26, 2021
by
Maurelian
Committed by
Kelvin Fichter
Nov 10, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(contracts): Get artifacts from deployments
Rather than adding additional config args to npx hardhat deploy
parent
6bc84976
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
56 additions
and
119 deletions
+56
-119
001-OVM_ChainStorageContainer_ctc_batches.deploy.ts
...eploy/001-OVM_ChainStorageContainer_ctc_batches.deploy.ts
+2
-2
002-OVM_ChainStorageContainer_scc_batches.deploy.ts
...eploy/002-OVM_ChainStorageContainer_scc_batches.deploy.ts
+2
-2
003-OVM_CanonicalTransactionChain.deploy.ts
...tracts/deploy/003-OVM_CanonicalTransactionChain.deploy.ts
+2
-2
004-OVM_StateCommitmentChain.deploy.ts
...s/contracts/deploy/004-OVM_StateCommitmentChain.deploy.ts
+2
-2
005-OVM_BondManager.deploy.ts
packages/contracts/deploy/005-OVM_BondManager.deploy.ts
+2
-2
006-OVM_L1CrossDomainMessenger.deploy.ts
...contracts/deploy/006-OVM_L1CrossDomainMessenger.deploy.ts
+2
-2
007-Proxy__OVM_L1CrossDomainMessenger.deploy.ts
...ts/deploy/007-Proxy__OVM_L1CrossDomainMessenger.deploy.ts
+2
-2
009-OVM_L1StandardBridge.deploy.ts
packages/contracts/deploy/009-OVM_L1StandardBridge.deploy.ts
+3
-3
010-AddressSetter.deploy.ts
packages/contracts/deploy/010-AddressSetter.deploy.ts
+3
-3
011-set-addresses.ts
packages/contracts/deploy/011-set-addresses.ts
+3
-3
012-initialize-Proxy__L1CrossDomainMessenger.ts
...ts/deploy/012-initialize-Proxy__L1CrossDomainMessenger.ts
+3
-3
013-finalize.ts
packages/contracts/deploy/013-finalize.ts
+2
-2
014-fund-accounts.ts
packages/contracts/deploy/014-fund-accounts.ts
+2
-2
hardhat-deploy-ethers.ts
packages/contracts/src/hardhat-deploy-ethers.ts
+26
-54
deploy.ts
packages/contracts/tasks/deploy.ts
+0
-35
No files found.
packages/contracts/deploy/001-OVM_ChainStorageContainer_ctc_batches.deploy.ts
View file @
b3b97959
...
...
@@ -4,11 +4,11 @@ import { DeployFunction } from 'hardhat-deploy/dist/types'
/* Imports: Internal */
import
{
deployAndPostDeploy
,
get
LiveContr
act
,
get
ContractFromArtif
act
,
}
from
'
../src/hardhat-deploy-ethers
'
const
deployFn
:
DeployFunction
=
async
(
hre
)
=>
{
const
Lib_AddressManager
=
await
get
LiveContr
act
(
hre
,
'
Lib_AddressManager
'
)
const
Lib_AddressManager
=
await
get
ContractFromArtif
act
(
hre
,
'
Lib_AddressManager
'
)
await
deployAndPostDeploy
({
hre
,
...
...
packages/contracts/deploy/002-OVM_ChainStorageContainer_scc_batches.deploy.ts
View file @
b3b97959
...
...
@@ -4,11 +4,11 @@ import { DeployFunction } from 'hardhat-deploy/dist/types'
/* Imports: Internal */
import
{
deployAndPostDeploy
,
get
LiveContr
act
,
get
ContractFromArtif
act
,
}
from
'
../src/hardhat-deploy-ethers
'
const
deployFn
:
DeployFunction
=
async
(
hre
)
=>
{
const
Lib_AddressManager
=
await
get
LiveContr
act
(
hre
,
'
Lib_AddressManager
'
)
const
Lib_AddressManager
=
await
get
ContractFromArtif
act
(
hre
,
'
Lib_AddressManager
'
)
await
deployAndPostDeploy
({
hre
,
...
...
packages/contracts/deploy/003-OVM_CanonicalTransactionChain.deploy.ts
View file @
b3b97959
...
...
@@ -4,11 +4,11 @@ import { DeployFunction } from 'hardhat-deploy/dist/types'
/* Imports: Internal */
import
{
deployAndPostDeploy
,
get
LiveContr
act
,
get
ContractFromArtif
act
,
}
from
'
../src/hardhat-deploy-ethers
'
const
deployFn
:
DeployFunction
=
async
(
hre
)
=>
{
const
Lib_AddressManager
=
await
get
LiveContr
act
(
hre
,
'
Lib_AddressManager
'
)
const
Lib_AddressManager
=
await
get
ContractFromArtif
act
(
hre
,
'
Lib_AddressManager
'
)
await
deployAndPostDeploy
({
hre
,
...
...
packages/contracts/deploy/004-OVM_StateCommitmentChain.deploy.ts
View file @
b3b97959
...
...
@@ -4,11 +4,11 @@ import { DeployFunction } from 'hardhat-deploy/dist/types'
/* Imports: Internal */
import
{
deployAndPostDeploy
,
get
LiveContr
act
,
get
ContractFromArtif
act
,
}
from
'
../src/hardhat-deploy-ethers
'
const
deployFn
:
DeployFunction
=
async
(
hre
)
=>
{
const
Lib_AddressManager
=
await
get
LiveContr
act
(
hre
,
'
Lib_AddressManager
'
)
const
Lib_AddressManager
=
await
get
ContractFromArtif
act
(
hre
,
'
Lib_AddressManager
'
)
await
deployAndPostDeploy
({
hre
,
...
...
packages/contracts/deploy/005-OVM_BondManager.deploy.ts
View file @
b3b97959
...
...
@@ -4,11 +4,11 @@ import { DeployFunction } from 'hardhat-deploy/dist/types'
/* Imports: Internal */
import
{
deployAndPostDeploy
,
get
LiveContr
act
,
get
ContractFromArtif
act
,
}
from
'
../src/hardhat-deploy-ethers
'
const
deployFn
:
DeployFunction
=
async
(
hre
)
=>
{
const
Lib_AddressManager
=
await
get
LiveContr
act
(
hre
,
'
Lib_AddressManager
'
)
const
Lib_AddressManager
=
await
get
ContractFromArtif
act
(
hre
,
'
Lib_AddressManager
'
)
await
deployAndPostDeploy
({
hre
,
...
...
packages/contracts/deploy/006-OVM_L1CrossDomainMessenger.deploy.ts
View file @
b3b97959
...
...
@@ -5,12 +5,12 @@ import { hexStringEquals } from '@eth-optimism/core-utils'
/* Imports: Internal */
import
{
deployAndPostDeploy
,
get
LiveContr
act
,
get
ContractFromArtif
act
,
waitUntilTrue
,
}
from
'
../src/hardhat-deploy-ethers
'
const
deployFn
:
DeployFunction
=
async
(
hre
)
=>
{
const
Lib_AddressManager
=
await
get
LiveContr
act
(
hre
,
'
Lib_AddressManager
'
)
const
Lib_AddressManager
=
await
get
ContractFromArtif
act
(
hre
,
'
Lib_AddressManager
'
)
await
deployAndPostDeploy
({
hre
,
...
...
packages/contracts/deploy/007-Proxy__OVM_L1CrossDomainMessenger.deploy.ts
View file @
b3b97959
...
...
@@ -5,12 +5,12 @@ import { hexStringEquals } from '@eth-optimism/core-utils'
/* Imports: Internal */
import
{
deployAndPostDeploy
,
get
LiveContr
act
,
get
ContractFromArtif
act
,
waitUntilTrue
,
}
from
'
../src/hardhat-deploy-ethers
'
const
deployFn
:
DeployFunction
=
async
(
hre
)
=>
{
const
Lib_AddressManager
=
await
get
LiveContr
act
(
hre
,
'
Lib_AddressManager
'
)
const
Lib_AddressManager
=
await
get
ContractFromArtif
act
(
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/009-OVM_L1StandardBridge.deploy.ts
View file @
b3b97959
...
...
@@ -10,7 +10,7 @@ import {
getContractDefinition
,
}
from
'
../src/contract-defs
'
import
{
get
LiveContr
act
,
get
ContractFromArtif
act
,
waitUntilTrue
,
getAdvancedContract
,
deployAndPostDeploy
,
...
...
@@ -20,7 +20,7 @@ const deployFn: DeployFunction = async (hre) => {
const
{
deployer
}
=
await
hre
.
getNamedAccounts
()
// Set up a reference to the proxy as if it were the L1StandardBridge contract.
const
contract
=
await
get
LiveContr
act
(
hre
,
'
Proxy__OVM_L1StandardBridge
'
,
{
const
contract
=
await
get
ContractFromArtif
act
(
hre
,
'
Proxy__OVM_L1StandardBridge
'
,
{
iface
:
'
L1StandardBridge
'
,
signerOrProvider
:
deployer
,
})
...
...
@@ -62,7 +62,7 @@ const deployFn: DeployFunction = async (hre) => {
// Next we need to set the `messenger` address by executing a setStorage operation. We'll
// check that this operation was correctly executed by calling `messenger()` and checking
// that the result matches the value we initialized.
const
l1CrossDomainMessenger
=
await
get
LiveContr
act
(
const
l1CrossDomainMessenger
=
await
get
ContractFromArtif
act
(
hre
,
'
Proxy__OVM_L1CrossDomainMessenger
'
)
...
...
packages/contracts/deploy/010-AddressSetter.deploy.ts
View file @
b3b97959
...
...
@@ -5,12 +5,12 @@ import { hexStringEquals } from '@eth-optimism/core-utils'
/* Imports: Internal */
import
{
deployAndPostDeploy
,
get
LiveContr
act
,
get
ContractFromArtif
act
,
}
from
'
../src/hardhat-deploy-ethers
'
import
{
predeploys
}
from
'
../src/predeploys
'
const
deployFn
:
DeployFunction
=
async
(
hre
)
=>
{
const
Lib_AddressManager
=
await
get
LiveContr
act
(
hre
,
'
Lib_AddressManager
'
)
const
Lib_AddressManager
=
await
get
ContractFromArtif
act
(
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.
...
...
@@ -32,7 +32,7 @@ const deployFn: DeployFunction = async (hre) => {
allContractNames
.
map
(
async
(
name
)
=>
{
return
{
name
,
address
:
(
await
get
LiveContr
act
(
hre
,
name
)).
address
,
address
:
(
await
get
ContractFromArtif
act
(
hre
,
name
)).
address
,
}
})
)
...
...
packages/contracts/deploy/011-set-addresses.ts
View file @
b3b97959
...
...
@@ -4,14 +4,14 @@ import { ethers } from 'hardhat'
import
{
DeployFunction
}
from
'
hardhat-deploy/dist/types
'
/* Imports: Internal */
import
{
get
LiveContr
act
,
waitUntilTrue
}
from
'
../src/hardhat-deploy-ethers
'
import
{
get
ContractFromArtif
act
,
waitUntilTrue
}
from
'
../src/hardhat-deploy-ethers
'
const
deployFn
:
DeployFunction
=
async
(
hre
)
=>
{
const
{
deployer
}
=
await
hre
.
getNamedAccounts
()
const
addressDictator
=
await
get
LiveContr
act
(
hre
,
'
AddressDictator
'
,
{
const
addressDictator
=
await
get
ContractFromArtif
act
(
hre
,
'
AddressDictator
'
,
{
signerOrProvider
:
deployer
,
})
const
libAddressManager
=
await
get
LiveContr
act
(
hre
,
'
Lib_AddressManager
'
)
const
libAddressManager
=
await
get
ContractFromArtif
act
(
hre
,
'
Lib_AddressManager
'
)
const
namedAddresses
=
await
addressDictator
.
getNamedAddresses
()
const
finalOwner
=
await
addressDictator
.
finalOwner
()
let
currentOwner
=
await
libAddressManager
.
owner
()
...
...
packages/contracts/deploy/012-initialize-Proxy__L1CrossDomainMessenger.ts
View file @
b3b97959
...
...
@@ -3,7 +3,7 @@ import { DeployFunction } from 'hardhat-deploy/dist/types'
import
{
hexStringEquals
}
from
'
@eth-optimism/core-utils
'
/* Imports: Internal */
import
{
get
LiveContr
act
,
waitUntilTrue
}
from
'
../src/hardhat-deploy-ethers
'
import
{
get
ContractFromArtif
act
,
waitUntilTrue
}
from
'
../src/hardhat-deploy-ethers
'
const
deployFn
:
DeployFunction
=
async
(
hre
)
=>
{
const
{
deployer
}
=
await
hre
.
getNamedAccounts
()
...
...
@@ -11,7 +11,7 @@ const deployFn: DeployFunction = async (hre) => {
// 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
=
await
get
LiveContr
act
(
const
proxy
=
await
get
ContractFromArtif
act
(
hre
,
'
Proxy__OVM_L1CrossDomainMessenger
'
,
{
...
...
@@ -19,7 +19,7 @@ const deployFn: DeployFunction = async (hre) => {
signerOrProvider
:
deployer
,
}
)
const
libAddressManager
=
await
get
LiveContr
act
(
hre
,
'
Lib_AddressManager
'
)
const
libAddressManager
=
await
get
ContractFromArtif
act
(
hre
,
'
Lib_AddressManager
'
)
await
proxy
.
initialize
(
libAddressManager
.
address
)
console
.
log
(
`Checking that contract was correctly initialized...`
)
...
...
packages/contracts/deploy/013-finalize.ts
View file @
b3b97959
...
...
@@ -3,11 +3,11 @@ import { DeployFunction } from 'hardhat-deploy/dist/types'
import
{
hexStringEquals
}
from
'
@eth-optimism/core-utils
'
/* Imports: Internal */
import
{
get
LiveContr
act
,
waitUntilTrue
}
from
'
../src/hardhat-deploy-ethers
'
import
{
get
ContractFromArtif
act
,
waitUntilTrue
}
from
'
../src/hardhat-deploy-ethers
'
const
deployFn
:
DeployFunction
=
async
(
hre
)
=>
{
const
{
deployer
}
=
await
hre
.
getNamedAccounts
()
const
Lib_AddressManager
=
await
get
LiveContr
act
(
hre
,
'
Lib_AddressManager
'
,
{
const
Lib_AddressManager
=
await
get
ContractFromArtif
act
(
hre
,
'
Lib_AddressManager
'
,
{
signerOrProvider
:
deployer
,
})
...
...
packages/contracts/deploy/014-fund-accounts.ts
View file @
b3b97959
...
...
@@ -8,7 +8,7 @@ import {
import
{
normalizeHardhatNetworkAccountsConfig
}
from
'
hardhat/internal/core/providers/util
'
/* Imports: Internal */
import
{
get
LiveContr
act
}
from
'
../src/hardhat-deploy-ethers
'
import
{
get
ContractFromArtif
act
}
from
'
../src/hardhat-deploy-ethers
'
// This is a TEMPORARY way to fund the default hardhat accounts on L2. The better way to do this is
// to make a modification to hardhat-ovm. However, I don't have the time right now to figure the
...
...
@@ -17,7 +17,7 @@ const deployFn: DeployFunction = async (hre) => {
// Only execute this step if we're on the hardhat chain ID.
const
{
chainId
}
=
await
hre
.
ethers
.
provider
.
getNetwork
()
if
(
chainId
===
defaultHardhatNetworkParams
.
chainId
)
{
const
L1StandardBridge
=
await
get
LiveContr
act
(
const
L1StandardBridge
=
await
get
ContractFromArtif
act
(
hre
,
'
Proxy__OVM_L1StandardBridge
'
,
{
...
...
packages/contracts/src/hardhat-deploy-ethers.ts
View file @
b3b97959
...
...
@@ -136,57 +136,6 @@ export const getAdvancedContract = (opts: {
return
contract
}
// 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
:
{
iface
?:
string
signerOrProvider
?:
Signer
|
Provider
|
string
}
=
{}
):
Promise
<
Contract
>
=>
{
// 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
))
{
// Get the interface by name, unless an override was requested via the iface option
const
factory
=
await
hre
.
ethers
.
getContractFactory
(
options
.
iface
||
name
)
return
new
Contract
(
addr
,
factory
.
interface
)
}
// Otherwise, look for a previously deployed contract.
const
deployed
=
await
hre
.
deployments
.
get
(
name
)
await
hre
.
ethers
.
provider
.
waitForTransaction
(
deployed
.
receipt
.
transactionHash
)
// Get the deployed contract's interface.
let
iface
=
new
hre
.
ethers
.
utils
.
Interface
(
deployed
.
abi
)
// Override with optional iface name if requested.
if
(
options
.
iface
)
{
const
factory
=
await
hre
.
ethers
.
getContractFactory
(
options
.
iface
)
iface
=
factory
.
interface
}
let
signerOrProvider
:
Signer
|
Provider
=
hre
.
ethers
.
provider
if
(
options
.
signerOrProvider
)
{
if
(
typeof
options
.
signerOrProvider
===
'
string
'
)
{
signerOrProvider
=
hre
.
ethers
.
provider
.
getSigner
(
options
.
signerOrProvider
)
}
else
{
signerOrProvider
=
options
.
signerOrProvider
}
}
return
getAdvancedContract
({
hre
,
contract
:
new
Contract
(
deployed
.
address
,
iface
,
signerOrProvider
),
})
}
export
const
fundAccount
=
async
(
hre
:
any
,
address
:
string
,
...
...
@@ -250,15 +199,38 @@ export const sendImpersonatedTx = async (opts: {
export
const
getContractFromArtifact
=
async
(
hre
:
any
,
name
:
string
name
:
string
,
options
:
{
iface
?:
string
signerOrProvider
?:
Signer
|
Provider
|
string
}
=
{}
):
Promise
<
ethers
.
Contract
>
=>
{
const
artifact
=
await
hre
.
deployments
.
get
(
name
)
await
hre
.
ethers
.
provider
.
waitForTransaction
(
artifact
.
receipt
.
transactionHash
)
// Get the deployed contract's interface.
let
iface
=
new
hre
.
ethers
.
utils
.
Interface
(
artifact
.
abi
)
// Override with optional iface name if requested.
if
(
options
.
iface
)
{
const
factory
=
await
hre
.
ethers
.
getContractFactory
(
options
.
iface
)
iface
=
factory
.
interface
}
let
signerOrProvider
:
Signer
|
Provider
=
hre
.
ethers
.
provider
if
(
options
.
signerOrProvider
)
{
if
(
typeof
options
.
signerOrProvider
===
'
string
'
)
{
signerOrProvider
=
hre
.
ethers
.
provider
.
getSigner
(
options
.
signerOrProvider
)
}
else
{
signerOrProvider
=
options
.
signerOrProvider
}
}
return
getAdvancedContract
({
hre
,
contract
:
new
hre
.
ethers
.
Contract
(
artifact
.
address
,
artifact
.
abi
,
hre
.
ethers
.
p
rovider
iface
,
signerOrP
rovider
),
})
}
...
...
packages/contracts/tasks/deploy.ts
View file @
b3b97959
...
...
@@ -118,41 +118,6 @@ task('deploy')
validateAddressArg
(
'
ovmProposerAddress
'
)
validateAddressArg
(
'
ovmAddressManagerOwner
'
)
// Validate potentially conflicting arguments
// When are argName is provided, it indicates an address that will be reused in this deployment.
// When a tagName is provided, it indicates that a new contract will be deployed.
const
validateArgOrTag
=
(
argName
:
string
,
tagName
:
string
)
=>
{
// The 'fresh' tag tells us that a new copy of each contract will be deployed.
const
hasTag
=
args
.
tags
.
includes
(
tagName
)
// Ensure that an arg and tag were NOT BOTH provided for a given contract
if
(
hasTag
&&
ethers
.
utils
.
isAddress
(
args
[
argName
]))
{
throw
new
Error
(
`cannot deploy a new
${
tagName
}
if the address of an existing one is provided`
)
}
// Ensure that either a valid address is provided OR that we deploy a new one.
try
{
validateAddressArg
(
argName
)
console
.
log
(
`Running deployments with the existing
${
tagName
}
at
${
args
[
argName
]}
`
)
}
catch
(
error
)
{
if
(
!
hasTag
)
{
throw
new
Error
(
`
${
error
.
message
}
\nmust either deploy a new
${
tagName
}
, or provide the address for an existing one`
)
}
console
.
log
(
`Running deployments with a new
${
tagName
}
`
)
}
}
validateArgOrTag
(
'
libAddressManager
'
,
'
Lib_AddressManager
'
)
validateArgOrTag
(
'
proxyL1CrossDomainMessenger
'
,
'
Proxy__OVM_L1CrossDomainMessenger
'
)
validateArgOrTag
(
'
proxyL1StandardBridge
'
,
'
Proxy__OVM_L1StandardBridge
'
)
hre
.
deployConfig
=
args
return
runSuper
(
args
)
})
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