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
564746eb
Unverified
Commit
564746eb
authored
Dec 07, 2022
by
Kelvin Fichter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
maint(ctb): add comments to deploy utils
Adds comments to existing deploy utils.
parent
f4cd5c0e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
53 additions
and
15 deletions
+53
-15
deploy-utils.ts
packages/contracts-bedrock/src/deploy-utils.ts
+53
-15
No files found.
packages/contracts-bedrock/src/deploy-utils.ts
View file @
564746eb
...
@@ -5,10 +5,10 @@ import { Provider } from '@ethersproject/abstract-provider'
...
@@ -5,10 +5,10 @@ import { Provider } from '@ethersproject/abstract-provider'
import
{
Signer
}
from
'
@ethersproject/abstract-signer
'
import
{
Signer
}
from
'
@ethersproject/abstract-signer
'
import
{
sleep
}
from
'
@eth-optimism/core-utils
'
import
{
sleep
}
from
'
@eth-optimism/core-utils
'
import
{
HardhatRuntimeEnvironment
}
from
'
hardhat/types
'
import
{
HardhatRuntimeEnvironment
}
from
'
hardhat/types
'
import
{
Deployment
,
DeployResult
}
from
'
hardhat-deploy/dist/types
'
import
'
hardhat-deploy
'
import
'
hardhat-deploy
'
import
'
@eth-optimism/hardhat-deploy-config
'
import
'
@eth-optimism/hardhat-deploy-config
'
import
'
@nomiclabs/hardhat-ethers
'
import
'
@nomiclabs/hardhat-ethers
'
import
{
Deployment
,
DeployResult
}
from
'
hardhat-deploy/dist/types
'
/**
/**
* Wrapper around hardhat-deploy with some extra features.
* Wrapper around hardhat-deploy with some extra features.
...
@@ -80,11 +80,18 @@ export const deploy = async ({
...
@@ -80,11 +80,18 @@ export const deploy = async ({
return
created
return
created
}
}
// Returns a version of the contract object which modifies all of the input contract's methods to:
/**
// 1. Waits for a confirmed receipt with more than deployConfig.numDeployConfirmations confirmations.
* Returns a version of the contract object which modifies all of the input contract's methods to:
// 2. Include simple resubmission logic, ONLY for Kovan, which appears to drop transactions.
* 1. Waits for a confirmed receipt with more than numDeployConfirmations confirmations.
* 2. Include simple resubmission logic, ONLY for Kovan, which appears to drop transactions.
*
* @param opts Options for the contract.
* @param opts.hre HardhatRuntimeEnvironment.
* @param opts.contract Contract to wrap.
* @returns Wrapped contract object.
*/
export
const
getAdvancedContract
=
(
opts
:
{
export
const
getAdvancedContract
=
(
opts
:
{
hre
:
any
hre
:
HardhatRuntimeEnvironment
contract
:
Contract
contract
:
Contract
}):
Contract
=>
{
}):
Contract
=>
{
// Temporarily override Object.defineProperty to bypass ether's object protection.
// Temporarily override Object.defineProperty to bypass ether's object protection.
...
@@ -159,10 +166,20 @@ export const getAdvancedContract = (opts: {
...
@@ -159,10 +166,20 @@ export const getAdvancedContract = (opts: {
return
contract
return
contract
}
}
/**
* Creates a contract object from a deployed artifact.
*
* @param hre HardhatRuntimeEnvironment.
* @param name Name of the deployed contract to get an object for.
* @param opts Options for the contract.
* @param opts.iface Optional interface to use for the contract object.
* @param opts.signerOrProvider Optional signer or provider to use for the contract object.
* @returns Contract object.
*/
export
const
getContractFromArtifact
=
async
(
export
const
getContractFromArtifact
=
async
(
hre
:
any
,
hre
:
HardhatRuntimeEnvironment
,
name
:
string
,
name
:
string
,
opt
ion
s
:
{
opts
:
{
iface
?:
string
iface
?:
string
signerOrProvider
?:
Signer
|
Provider
|
string
signerOrProvider
?:
Signer
|
Provider
|
string
}
=
{}
}
=
{}
...
@@ -173,17 +190,17 @@ export const getContractFromArtifact = async (
...
@@ -173,17 +190,17 @@ export const getContractFromArtifact = async (
// Get the deployed contract's interface.
// Get the deployed contract's interface.
let
iface
=
new
hre
.
ethers
.
utils
.
Interface
(
artifact
.
abi
)
let
iface
=
new
hre
.
ethers
.
utils
.
Interface
(
artifact
.
abi
)
// Override with optional iface name if requested.
// Override with optional iface name if requested.
if
(
opt
ion
s
.
iface
)
{
if
(
opts
.
iface
)
{
const
factory
=
await
hre
.
ethers
.
getContractFactory
(
opt
ion
s
.
iface
)
const
factory
=
await
hre
.
ethers
.
getContractFactory
(
opts
.
iface
)
iface
=
factory
.
interface
iface
=
factory
.
interface
}
}
let
signerOrProvider
:
Signer
|
Provider
=
hre
.
ethers
.
provider
let
signerOrProvider
:
Signer
|
Provider
=
hre
.
ethers
.
provider
if
(
opt
ion
s
.
signerOrProvider
)
{
if
(
opts
.
signerOrProvider
)
{
if
(
typeof
opt
ion
s
.
signerOrProvider
===
'
string
'
)
{
if
(
typeof
opts
.
signerOrProvider
===
'
string
'
)
{
signerOrProvider
=
hre
.
ethers
.
provider
.
getSigner
(
opt
ion
s
.
signerOrProvider
)
signerOrProvider
=
hre
.
ethers
.
provider
.
getSigner
(
opts
.
signerOrProvider
)
}
else
{
}
else
{
signerOrProvider
=
opt
ion
s
.
signerOrProvider
signerOrProvider
=
opts
.
signerOrProvider
}
}
}
}
...
@@ -197,8 +214,15 @@ export const getContractFromArtifact = async (
...
@@ -197,8 +214,15 @@ export const getContractFromArtifact = async (
})
})
}
}
/**
* Gets multiple contract objects from their respective deployed artifacts.
*
* @param hre HardhatRuntimeEnvironment.
* @param configs Array of contract names and options.
* @returns Array of contract objects.
*/
export
const
getContractsFromArtifacts
=
async
(
export
const
getContractsFromArtifacts
=
async
(
hre
:
any
,
hre
:
HardhatRuntimeEnvironment
,
configs
:
Array
<
{
configs
:
Array
<
{
name
:
string
name
:
string
iface
?:
string
iface
?:
string
...
@@ -212,6 +236,13 @@ export const getContractsFromArtifacts = async (
...
@@ -212,6 +236,13 @@ export const getContractsFromArtifacts = async (
return
contracts
return
contracts
}
}
/**
* Helper function for asserting that a contract variable is set to the expected value.
*
* @param contract Contract object to query.
* @param variable Name of the variable to query.
* @param expected Expected value of the variable.
*/
export
const
assertContractVariable
=
async
(
export
const
assertContractVariable
=
async
(
contract
:
ethers
.
Contract
,
contract
:
ethers
.
Contract
,
variable
:
string
,
variable
:
string
,
...
@@ -243,8 +274,15 @@ export const assertContractVariable = async (
...
@@ -243,8 +274,15 @@ export const assertContractVariable = async (
)
)
}
}
/**
* Returns the address for a given deployed contract by name.
*
* @param hre HardhatRuntimeEnvironment.
* @param name Name of the deployed contract.
* @returns Address of the deployed contract.
*/
export
const
getDeploymentAddress
=
async
(
export
const
getDeploymentAddress
=
async
(
hre
:
any
,
hre
:
HardhatRuntimeEnvironment
,
name
:
string
name
:
string
):
Promise
<
string
>
=>
{
):
Promise
<
string
>
=>
{
const
deployment
=
await
hre
.
deployments
.
get
(
name
)
const
deployment
=
await
hre
.
deployments
.
get
(
name
)
...
...
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