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
642e1dab
Commit
642e1dab
authored
Apr 05, 2023
by
Maurelian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(ctb): Add doPhase to deploy utils
parent
06f5bd89
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
77 additions
and
1 deletion
+77
-1
deploy-utils.ts
packages/contracts-bedrock/src/deploy-utils.ts
+77
-1
No files found.
packages/contracts-bedrock/src/deploy-utils.ts
View file @
642e1dab
...
...
@@ -333,6 +333,25 @@ export const isStep = async (
return
(
await
dictator
.
currentStep
())
===
step
}
/**
* Mini helper for checking if the current step is the first step in target phase.
*
* @param dictator SystemDictator contract.
* @param phase Target phase.
* @returns True if the current step is the first step in target phase.
*/
export
const
isStartOfPhase
=
async
(
dictator
:
ethers
.
Contract
,
phase
:
number
):
Promise
<
boolean
>
=>
{
const
phaseToStep
=
{
1
:
1
,
2
:
3
,
3
:
6
,
}
return
(
await
dictator
.
currentStep
())
===
phaseToStep
[
phase
]
}
/**
* Mini helper for executing a given step.
*
...
...
@@ -350,7 +369,8 @@ export const doStep = async (opts: {
message
:
string
checks
:
()
=>
Promise
<
void
>
}):
Promise
<
void
>
=>
{
if
(
!
(
await
isStep
(
opts
.
SystemDictator
,
opts
.
step
)))
{
const
isStepVal
=
await
isStep
(
opts
.
SystemDictator
,
opts
.
step
)
if
(
!
isStepVal
)
{
console
.
log
(
`Step already completed:
${
opts
.
step
}
`
)
return
}
...
...
@@ -388,6 +408,62 @@ export const doStep = async (opts: {
await
opts
.
checks
()
}
/**
* Mini helper for executing a given phase.
*
* @param opts Options for executing the step.
* @param opts.isLiveDeployer True if the deployer is live.
* @param opts.SystemDictator SystemDictator contract.
* @param opts.step Step to execute.
* @param opts.message Message to print before executing the step.
* @param opts.checks Checks to perform after executing the step.
*/
export
const
doPhase
=
async
(
opts
:
{
isLiveDeployer
?:
boolean
SystemDictator
:
ethers
.
Contract
phase
:
number
message
:
string
checks
:
()
=>
Promise
<
void
>
}):
Promise
<
void
>
=>
{
const
isStart
=
await
isStartOfPhase
(
opts
.
SystemDictator
,
opts
.
phase
)
if
(
!
isStart
)
{
console
.
log
(
`Start of phase
${
opts
.
phase
}
already completed`
)
return
}
// Extra message to help the user understand what's going on.
console
.
log
(
opts
.
message
)
// Either automatically or manually execute the step.
if
(
opts
.
isLiveDeployer
)
{
console
.
log
(
`Executing phase
${
opts
.
phase
}
...`
)
await
opts
.
SystemDictator
[
`phase
${
opts
.
phase
}
`
]()
}
else
{
const
tx
=
await
opts
.
SystemDictator
.
populateTransaction
[
`phase
${
opts
.
phase
}
`
]()
console
.
log
(
`Please execute phase
${
opts
.
phase
}
...`
)
console
.
log
(
`MSD address:
${
opts
.
SystemDictator
.
address
}
`
)
console
.
log
(
`JSON:`
)
console
.
log
(
jsonifyTransaction
(
tx
))
console
.
log
(
await
getTenderlySimulationLink
(
opts
.
SystemDictator
.
provider
,
tx
)
)
}
// Wait for the step to complete.
await
awaitCondition
(
async
()
=>
{
return
isStartOfPhase
(
opts
.
SystemDictator
,
opts
.
phase
+
1
)
},
30000
,
1000
)
// Perform post-step checks.
await
opts
.
checks
()
}
/**
* Returns a direct link to a Tenderly simulation.
*
...
...
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