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
df6da1e4
Commit
df6da1e4
authored
Apr 05, 2023
by
James Kim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update deploy to be idempotent
parent
b1e9c0e2
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
13 deletions
+24
-13
localhost.ts
packages/contracts-periphery/config/deploy/localhost.ts
+5
-0
setupProxyContract.ts
...ges/contracts-periphery/src/helpers/setupProxyContract.ts
+19
-13
No files found.
packages/contracts-periphery/config/deploy/localhost.ts
0 → 100644
View file @
df6da1e4
import
config
from
'
./hardhat
'
// uses the same config as hardhat.ts
export
default
config
packages/contracts-periphery/src/helpers/setupProxyContract.ts
View file @
df6da1e4
...
@@ -18,7 +18,7 @@ type ProxyConfig = {
...
@@ -18,7 +18,7 @@ type ProxyConfig = {
const
setupProxyContract
=
async
(
const
setupProxyContract
=
async
(
proxyContract
:
ethers
.
Contract
,
proxyContract
:
ethers
.
Contract
,
proxyOwnerS
igner
:
ethers
.
Signer
,
s
igner
:
ethers
.
Signer
,
{
{
targetImplAddress
,
targetImplAddress
,
targetProxyOwnerAddress
,
targetProxyOwnerAddress
,
...
@@ -29,13 +29,7 @@ const setupProxyContract = async (
...
@@ -29,13 +29,7 @@ const setupProxyContract = async (
.
connect
(
ethers
.
constants
.
AddressZero
)
.
connect
(
ethers
.
constants
.
AddressZero
)
.
callStatic
.
admin
()
.
callStatic
.
admin
()
// The proxy owner signer needs to be the current admin, otherwise we don't have permission
const
signerAddress
=
await
signer
.
getAddress
()
// to update the implmentation or admin
const
proxyOwnerSignerAddress
=
await
proxyOwnerSigner
.
getAddress
()
assert
(
proxyOwnerSignerAddress
===
currentAdmin
,
'
proxyOwnerSigner is not the admin
'
)
// Gets the current implementation address the proxy is pointing to.
// Gets the current implementation address the proxy is pointing to.
// callStatic is used since the `Proxy.implementation()` is not a view function and ethers will
// callStatic is used since the `Proxy.implementation()` is not a view function and ethers will
...
@@ -54,15 +48,20 @@ const setupProxyContract = async (
...
@@ -54,15 +48,20 @@ const setupProxyContract = async (
console
.
log
(
'
implementation not set to correct contract
'
)
console
.
log
(
'
implementation not set to correct contract
'
)
console
.
log
(
`Setting implementation to
${
targetImplAddress
}
`
)
console
.
log
(
`Setting implementation to
${
targetImplAddress
}
`
)
// The signer needs to be the current admin, otherwise we don't have permission
// to update the implmentation or admin
assert
(
signerAddress
===
currentAdmin
,
'
the passed signer is not the admin, cannot update implementation
'
)
let
tx
:
ethers
.
providers
.
TransactionResponse
let
tx
:
ethers
.
providers
.
TransactionResponse
if
(
!
postUpgradeCallCalldata
)
{
if
(
!
postUpgradeCallCalldata
)
{
console
.
log
(
console
.
log
(
'
postUpgradeCallCalldata is not provided. Using Proxy.upgrade()
'
'
postUpgradeCallCalldata is not provided. Using Proxy.upgrade()
'
)
)
// Point the proxy to the target implementation
// Point the proxy to the target implementation
tx
=
await
proxyContract
tx
=
await
proxyContract
.
connect
(
signer
).
upgradeTo
(
targetImplAddress
)
.
connect
(
proxyOwnerSigner
)
.
upgradeTo
(
targetImplAddress
)
}
else
{
}
else
{
console
.
log
(
console
.
log
(
'
postUpgradeCallCalldata is provided. Using Proxy.upgradeAndCall()
'
'
postUpgradeCallCalldata is provided. Using Proxy.upgradeAndCall()
'
...
@@ -70,7 +69,7 @@ const setupProxyContract = async (
...
@@ -70,7 +69,7 @@ const setupProxyContract = async (
// Point the proxy to the target implementation,
// Point the proxy to the target implementation,
// and call function in the proxy's context
// and call function in the proxy's context
tx
=
await
proxyContract
tx
=
await
proxyContract
.
connect
(
proxyOwnerS
igner
)
.
connect
(
s
igner
)
.
upgradeToAndCall
(
targetImplAddress
,
postUpgradeCallCalldata
)
.
upgradeToAndCall
(
targetImplAddress
,
postUpgradeCallCalldata
)
}
}
...
@@ -89,9 +88,16 @@ const setupProxyContract = async (
...
@@ -89,9 +88,16 @@ const setupProxyContract = async (
console
.
log
(
'
detected admin is not set correctly
'
)
console
.
log
(
'
detected admin is not set correctly
'
)
console
.
log
(
`Setting admin to
${
targetProxyOwnerAddress
}
`
)
console
.
log
(
`Setting admin to
${
targetProxyOwnerAddress
}
`
)
// The signer needs to be the current admin, otherwise we don't have permission
// to update the implmentation or admin
assert
(
signerAddress
===
currentAdmin
,
'
proxyOwnerSigner is not the admin, cannot update admin
'
)
// change admin to the l2ProxyOwnerAddress
// change admin to the l2ProxyOwnerAddress
const
tx
=
await
proxyContract
const
tx
=
await
proxyContract
.
connect
(
proxyOwnerS
igner
)
.
connect
(
s
igner
)
.
changeAdmin
(
targetProxyOwnerAddress
)
.
changeAdmin
(
targetProxyOwnerAddress
)
const
receipt
=
await
tx
.
wait
()
const
receipt
=
await
tx
.
wait
()
...
...
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