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
b1e9c0e2
Commit
b1e9c0e2
authored
Apr 04, 2023
by
James Kim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update Optimist and OptimistAllowlist deploy scripts
parent
18747f11
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
457 additions
and
135 deletions
+457
-135
ethereum.ts
packages/contracts-periphery/config/deploy/ethereum.ts
+4
-2
goerli.ts
packages/contracts-periphery/config/deploy/goerli.ts
+5
-1
hardhat.ts
packages/contracts-periphery/config/deploy/hardhat.ts
+5
-1
mainnet.ts
packages/contracts-periphery/config/deploy/mainnet.ts
+5
-1
optimism-goerli.ts
...ages/contracts-periphery/config/deploy/optimism-goerli.ts
+6
-1
optimism.ts
packages/contracts-periphery/config/deploy/optimism.ts
+5
-1
OptimistAllowlistImpl.ts
...ontracts-periphery/deploy/op-nft/OptimistAllowlistImpl.ts
+55
-0
OptimistAllowlistProxy.ts
...ntracts-periphery/deploy/op-nft/OptimistAllowlistProxy.ts
+153
-0
OptimistImpl.ts
packages/contracts-periphery/deploy/op-nft/OptimistImpl.ts
+14
-6
OptimistInviterImpl.ts
.../contracts-periphery/deploy/op-nft/OptimistInviterImpl.ts
+1
-1
OptimistInviterProxy.ts
...contracts-periphery/deploy/op-nft/OptimistInviterProxy.ts
+19
-72
OptimistProxy.ts
packages/contracts-periphery/deploy/op-nft/OptimistProxy.ts
+37
-47
deploy.ts
packages/contracts-periphery/src/config/deploy.ts
+22
-2
setupProxyContract.ts
...ges/contracts-periphery/src/helpers/setupProxyContract.ts
+126
-0
No files found.
packages/contracts-periphery/config/deploy/ethereum.ts
View file @
b1e9c0e2
...
...
@@ -5,9 +5,11 @@ const config: DeployConfig = {
l2ProxyOwnerAddress
:
''
,
optimistName
:
''
,
optimistSymbol
:
''
,
attestorAddress
:
''
,
optimistInviterName
:
''
,
optimistBaseUriAttestorAddress
:
''
,
optimistInviterInviteGranter
:
''
,
optimistInviterName
:
''
,
optimistAllowlistAllowlistAttestor
:
''
,
optimistAllowlistCoinbaseQuestAttestor
:
''
,
}
export
default
config
packages/contracts-periphery/config/deploy/goerli.ts
View file @
b1e9c0e2
...
...
@@ -5,9 +5,13 @@ const config: DeployConfig = {
l2ProxyOwnerAddress
:
'
0x60c5C9c98bcBd0b0F2fD89B24c16e533BaA8CdA3
'
,
optimistName
:
'
Optimist
'
,
optimistSymbol
:
'
OPTIMIST
'
,
a
ttestorAddress
:
'
0x60c5C9c98bcBd0b0F2fD89B24c16e533BaA8CdA3
'
,
optimistBaseUriA
ttestorAddress
:
'
0x60c5C9c98bcBd0b0F2fD89B24c16e533BaA8CdA3
'
,
optimistInviterInviteGranter
:
'
0x60c5C9c98bcBd0b0F2fD89B24c16e533BaA8CdA3
'
,
optimistInviterName
:
'
OptimistInviter
'
,
optimistAllowlistAllowlistAttestor
:
'
0x60c5C9c98bcBd0b0F2fD89B24c16e533BaA8CdA3
'
,
optimistAllowlistCoinbaseQuestAttestor
:
'
0x661B7Acca8ebd93AFd349a088e9a9A00053DB1BF
'
,
}
export
default
config
packages/contracts-periphery/config/deploy/hardhat.ts
View file @
b1e9c0e2
...
...
@@ -5,9 +5,13 @@ const config: DeployConfig = {
l2ProxyOwnerAddress
:
'
0x70997970c51812dc3a010c7d01b50e0d17dc79c8
'
,
optimistName
:
'
OP Citizenship
'
,
optimistSymbol
:
'
OPNFT
'
,
a
ttestorAddress
:
'
0x70997970c51812dc3a010c7d01b50e0d17dc79c8
'
,
optimistBaseUriA
ttestorAddress
:
'
0x70997970c51812dc3a010c7d01b50e0d17dc79c8
'
,
optimistInviterInviteGranter
:
'
0x70997970c51812dc3a010c7d01b50e0d17dc79c8
'
,
optimistInviterName
:
'
OptimistInviter
'
,
optimistAllowlistAllowlistAttestor
:
'
0x70997970c51812dc3a010c7d01b50e0d17dc79c8
'
,
optimistAllowlistCoinbaseQuestAttestor
:
'
0x70997970c51812dc3a010c7d01b50e0d17dc79c8
'
,
}
export
default
config
packages/contracts-periphery/config/deploy/mainnet.ts
View file @
b1e9c0e2
...
...
@@ -5,9 +5,13 @@ const config: DeployConfig = {
l2ProxyOwnerAddress
:
'
0x60c5C9c98bcBd0b0F2fD89B24c16e533BaA8CdA3
'
,
optimistName
:
'
Optimist
'
,
optimistSymbol
:
'
OPTIMIST
'
,
a
ttestorAddress
:
'
0x60c5C9c98bcBd0b0F2fD89B24c16e533BaA8CdA3
'
,
optimistBaseUriA
ttestorAddress
:
'
0x60c5C9c98bcBd0b0F2fD89B24c16e533BaA8CdA3
'
,
optimistInviterInviteGranter
:
'
0x60c5C9c98bcBd0b0F2fD89B24c16e533BaA8CdA3
'
,
optimistInviterName
:
'
OptimistInviter
'
,
optimistAllowlistAllowlistAttestor
:
'
0x60c5C9c98bcBd0b0F2fD89B24c16e533BaA8CdA3
'
,
optimistAllowlistCoinbaseQuestAttestor
:
'
0x661B7Acca8ebd93AFd349a088e9a9A00053DB1BF
'
,
}
export
default
config
packages/contracts-periphery/config/deploy/optimism-goerli.ts
View file @
b1e9c0e2
...
...
@@ -2,12 +2,17 @@ import { DeployConfig } from '../../src'
const
config
:
DeployConfig
=
{
ddd
:
'
0x9C6373dE60c2D3297b18A8f964618ac46E011B58
'
,
// EcoPod test account
l2ProxyOwnerAddress
:
'
0x8F0EBDaA1cF7106bE861753B0f9F5c0250fE0819
'
,
optimistName
:
'
Optimist
'
,
optimistSymbol
:
'
OPTIMIST
'
,
a
ttestorAddress
:
'
0x8F0EBDaA1cF7106bE861753B0f9F5c0250fE0819
'
,
optimistBaseUriA
ttestorAddress
:
'
0x8F0EBDaA1cF7106bE861753B0f9F5c0250fE0819
'
,
optimistInviterInviteGranter
:
'
0x8F0EBDaA1cF7106bE861753B0f9F5c0250fE0819
'
,
optimistInviterName
:
'
OptimistInviter
'
,
optimistAllowlistAllowlistAttestor
:
'
0x8F0EBDaA1cF7106bE861753B0f9F5c0250fE0819
'
,
optimistAllowlistCoinbaseQuestAttestor
:
'
0x8F0EBDaA1cF7106bE861753B0f9F5c0250fE0819
'
,
}
export
default
config
packages/contracts-periphery/config/deploy/optimism.ts
View file @
b1e9c0e2
...
...
@@ -5,9 +5,13 @@ const config: DeployConfig = {
l2ProxyOwnerAddress
:
'
0x60c5C9c98bcBd0b0F2fD89B24c16e533BaA8CdA3
'
,
optimistName
:
'
Optimist
'
,
optimistSymbol
:
'
OPTIMIST
'
,
a
ttestorAddress
:
'
0x60c5C9c98bcBd0b0F2fD89B24c16e533BaA8CdA3
'
,
optimistBaseUriA
ttestorAddress
:
'
0x60c5C9c98bcBd0b0F2fD89B24c16e533BaA8CdA3
'
,
optimistInviterInviteGranter
:
'
0x60c5C9c98bcBd0b0F2fD89B24c16e533BaA8CdA3
'
,
optimistInviterName
:
'
OptimistInviter
'
,
optimistAllowlistAllowlistAttestor
:
'
0x60c5C9c98bcBd0b0F2fD89B24c16e533BaA8CdA3
'
,
optimistAllowlistCoinbaseQuestAttestor
:
'
0x661B7Acca8ebd93AFd349a088e9a9A00053DB1BF
'
,
}
export
default
config
packages/contracts-periphery/deploy/op-nft/OptimistAllowlistImpl.ts
0 → 100644
View file @
b1e9c0e2
/* Imports: External */
import
{
DeployFunction
}
from
'
hardhat-deploy/dist/types
'
import
{
HardhatRuntimeEnvironment
}
from
'
hardhat/types
'
import
'
@nomiclabs/hardhat-ethers
'
import
'
@eth-optimism/hardhat-deploy-config
'
import
'
hardhat-deploy
'
import
type
{
DeployConfig
}
from
'
../../src
'
const
deployFn
:
DeployFunction
=
async
(
hre
:
HardhatRuntimeEnvironment
)
=>
{
const
deployConfig
=
hre
.
deployConfig
as
DeployConfig
const
{
deployer
}
=
await
hre
.
getNamedAccounts
()
console
.
log
(
`Deploying OptimistAllowlist implementation with
${
deployer
}
`
)
const
Deployment__AttestationStation
=
await
hre
.
deployments
.
get
(
'
AttestationStationProxy
'
)
const
Deployment__OptimistInviter
=
await
hre
.
deployments
.
get
(
'
OptimistInviterProxy
'
)
const
attestationStationAddress
=
Deployment__AttestationStation
.
address
const
optimistInviterAddress
=
Deployment__OptimistInviter
.
address
console
.
log
(
`Using
${
attestationStationAddress
}
as the ATTESTATION_STATION`
)
console
.
log
(
`Using
${
deployConfig
.
optimistAllowlistAllowlistAttestor
}
as ALLOWLIST_ATTESTOR`
)
console
.
log
(
`Using
${
deployConfig
.
optimistAllowlistCoinbaseQuestAttestor
}
as COINBASE_QUEST_ATTESTOR`
)
console
.
log
(
`Using
${
optimistInviterAddress
}
as OPTIMIST_INVITER`
)
const
{
deploy
}
=
await
hre
.
deployments
.
deterministic
(
'
OptimistAllowlist
'
,
{
salt
:
hre
.
ethers
.
utils
.
solidityKeccak256
([
'
string
'
],
[
'
OptimistAllowlist
'
]),
from
:
deployer
,
args
:
[
attestationStationAddress
,
deployConfig
.
optimistAllowlistAllowlistAttestor
,
deployConfig
.
optimistAllowlistCoinbaseQuestAttestor
,
optimistInviterAddress
,
],
log
:
true
,
})
await
deploy
()
}
deployFn
.
tags
=
[
'
OptimistAllowlistImpl
'
,
'
OptimistEnvironment
'
]
deployFn
.
dependencies
=
[
'
AttestationStationProxy
'
,
'
OptimistInviterProxy
'
]
export
default
deployFn
packages/contracts-periphery/deploy/op-nft/OptimistAllowlistProxy.ts
0 → 100644
View file @
b1e9c0e2
/* Imports: External */
import
assert
from
'
assert
'
import
{
DeployFunction
}
from
'
hardhat-deploy/dist/types
'
import
{
HardhatRuntimeEnvironment
}
from
'
hardhat/types
'
import
'
@eth-optimism/hardhat-deploy-config
'
import
'
@nomiclabs/hardhat-ethers
'
import
'
hardhat-deploy
'
import
{
assertContractVariable
}
from
'
@eth-optimism/contracts-bedrock/src/deploy-utils
'
import
{
ethers
,
utils
}
from
'
ethers
'
import
type
{
DeployConfig
}
from
'
../../src
'
import
{
setupProxyContract
}
from
'
../../src/helpers/setupProxyContract
'
const
{
getAddress
}
=
utils
// Required conditions before deploying - Specified in `deployFn.dependencies`
// - AttestationStationProxy is deployed and points to the correct implementation
// - OptimistInviterProxy is deployed and points to the correct implementation
// - OptimistAllowlistImpl is deployed
//
// Steps
// 1. Deploy OptimistAllowlistProxy
// 2. Point the newly deployed proxy to the implementation, if it hasn't been done already
// 3. Update the admin of the proxy to the l2ProxyOwnerAddress, if it hasn't been done already
// 4. Basic sanity checks for contract variables
const
deployFn
:
DeployFunction
=
async
(
hre
:
HardhatRuntimeEnvironment
)
=>
{
const
deployConfig
=
hre
.
deployConfig
as
DeployConfig
// Deployer should be set in hardhat.config.ts
const
{
deployer
}
=
await
hre
.
getNamedAccounts
()
// We want the ability to deploy to a deterministic address, so we need the init bytecode to be
// consistent across deployments. The ddd will quickly transfer the ownership of the Proxy to a
// multisig after deployment.
//
// We need a consistent ddd, since the Proxy takes a `_admin` constructor argument, which
// affects the init bytecode and hence deployed address.
const
ddd
=
deployConfig
.
ddd
if
(
getAddress
(
deployer
)
!==
getAddress
(
ddd
))
{
// Not a hard requirement. We can deploy with any account and just set the `_admin` to the
// ddd, but requiring that the deployer is the same as the ddd minimizes number of hot wallets
// we need to keep track of during deployment.
throw
new
Error
(
'
Must deploy with the ddd
'
)
}
// Get the up to date deployment of the OptimistAllowlist contract
const
Deployment__OptimistAllowlistImpl
=
await
hre
.
deployments
.
get
(
'
OptimistAllowlist
'
)
console
.
log
(
`Deploying OptimistAllowlistProxy with
${
deployer
}
`
)
// Deploys the Proxy.sol contract with the `_admin` constructor param set to the ddd (=== deployer).
const
{
deploy
}
=
await
hre
.
deployments
.
deterministic
(
'
OptimistAllowlistProxy
'
,
{
salt
:
hre
.
ethers
.
utils
.
solidityKeccak256
(
[
'
string
'
],
[
'
OptimistAllowlistProxy
'
]
),
contract
:
'
Proxy
'
,
from
:
deployer
,
args
:
[
deployer
],
log
:
true
,
}
)
// Deploy the Proxy contract
await
deploy
()
const
Deployment__OptimistAllowlistProxy
=
await
hre
.
deployments
.
get
(
'
OptimistAllowlistProxy
'
)
console
.
log
(
`OptimistAllowlistProxy deployed to
${
Deployment__OptimistAllowlistProxy
.
address
}
`
)
// Deployed Proxy.sol contract
const
Proxy
=
await
hre
.
ethers
.
getContractAt
(
'
Proxy
'
,
Deployment__OptimistAllowlistProxy
.
address
)
// Deployed Proxy.sol contract with the OptimistAllowlist interface
const
OptimistAllowlist
=
await
hre
.
ethers
.
getContractAt
(
'
OptimistAllowlist
'
,
Deployment__OptimistAllowlistProxy
.
address
)
// ethers.Signer for the ddd. Should be the current owner of the Proxy.
const
dddSigner
=
await
hre
.
ethers
.
provider
.
getSigner
(
deployer
)
// intended admin of the Proxy
const
l2ProxyOwnerAddress
=
deployConfig
.
l2ProxyOwnerAddress
// setup the Proxy contract with correct implementation and admin
await
setupProxyContract
(
Proxy
,
dddSigner
,
{
targetImplAddress
:
Deployment__OptimistAllowlistImpl
.
address
,
targetProxyOwnerAddress
:
l2ProxyOwnerAddress
,
})
const
Deployment__AttestationStationProxy
=
await
hre
.
deployments
.
get
(
'
AttestationStationProxy
'
)
const
Deployment__OptimistInviter
=
await
hre
.
deployments
.
get
(
'
OptimistInviterProxy
'
)
await
assert
(
getAddress
(
await
Proxy
.
connect
(
ethers
.
constants
.
AddressZero
).
callStatic
.
admin
()
)
===
getAddress
(
l2ProxyOwnerAddress
)
)
await
assertContractVariable
(
OptimistAllowlist
,
'
version
'
,
'
1.0.0
'
)
await
assertContractVariable
(
OptimistAllowlist
,
'
ATTESTATION_STATION
'
,
Deployment__AttestationStationProxy
.
address
)
await
assertContractVariable
(
OptimistAllowlist
,
'
ALLOWLIST_ATTESTOR
'
,
deployConfig
.
optimistAllowlistAllowlistAttestor
)
await
assertContractVariable
(
OptimistAllowlist
,
'
COINBASE_QUEST_ATTESTOR
'
,
deployConfig
.
optimistAllowlistCoinbaseQuestAttestor
)
await
assertContractVariable
(
OptimistAllowlist
,
'
OPTIMIST_INVITER
'
,
Deployment__OptimistInviter
.
address
)
}
deployFn
.
tags
=
[
'
OptimistAllowlistProxy
'
,
'
OptimistEnvironment
'
]
deployFn
.
dependencies
=
[
'
AttestationStationProxy
'
,
'
OptimistInviterProxy
'
,
'
OptimistAllowlistImpl
'
,
]
export
default
deployFn
packages/contracts-periphery/deploy/op-nft/OptimistImpl.ts
View file @
b1e9c0e2
...
...
@@ -14,13 +14,19 @@ const deployFn: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
console
.
log
(
`Deploying Optimist implementation with
${
deployer
}
`
)
const
Deployment__AttestationStation
=
await
hre
.
deployments
.
get
(
const
Deployment__AttestationStation
Proxy
=
await
hre
.
deployments
.
get
(
'
AttestationStationProxy
'
)
const
attestationStationAddress
=
Deployment__AttestationStation
.
address
const
attestationStationAddress
=
Deployment__AttestationStationProxy
.
address
console
.
log
(
`Using
${
attestationStationAddress
}
as the ATTESTATION_STATION`
)
console
.
log
(
`Using
${
deployConfig
.
optimistBaseUriAttestorAddress
}
as BASE_URI_ATTESTOR`
)
console
.
log
(
`Using
${
attestationStationAddress
}
as the AttestationStation`
)
console
.
log
(
`Using
${
deployConfig
.
attestorAddress
}
as ATTESTOR`
)
const
Deployment__OptimistAllowlistProxy
=
await
hre
.
deployments
.
get
(
'
OptimistAllowlistProxy
'
)
const
optimistAllowlistAddress
=
Deployment__OptimistAllowlistProxy
.
address
const
{
deploy
}
=
await
hre
.
deployments
.
deterministic
(
'
Optimist
'
,
{
salt
:
hre
.
ethers
.
utils
.
solidityKeccak256
([
'
string
'
],
[
'
Optimist
'
]),
...
...
@@ -28,8 +34,9 @@ const deployFn: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
args
:
[
deployConfig
.
optimistName
,
deployConfig
.
optimistSymbol
,
deployConfig
.
a
ttestorAddress
,
deployConfig
.
optimistBaseUriA
ttestorAddress
,
attestationStationAddress
,
optimistAllowlistAddress
,
],
log
:
true
,
})
...
...
@@ -37,6 +44,7 @@ const deployFn: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
await
deploy
()
}
deployFn
.
tags
=
[
'
Optimist
'
,
'
OptimistEnvironment
'
]
deployFn
.
tags
=
[
'
OptimistImpl
'
,
'
OptimistEnvironment
'
]
deployFn
.
dependencies
=
[
'
AttestationStationProxy
'
,
'
OptimistAllowlistProxy
'
]
export
default
deployFn
packages/contracts-periphery/deploy/op-nft/OptimistInviterImpl.ts
View file @
b1e9c0e2
...
...
@@ -37,7 +37,7 @@ const deployFn: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
await
deploy
()
}
deployFn
.
tags
=
[
'
OptimistInviter
'
,
'
OptimistEnvironment
'
]
deployFn
.
tags
=
[
'
OptimistInviter
Impl
'
,
'
OptimistEnvironment
'
]
deployFn
.
dependencies
=
[
'
AttestationStationProxy
'
]
export
default
deployFn
packages/contracts-periphery/deploy/op-nft/OptimistInviterProxy.ts
View file @
b1e9c0e2
...
...
@@ -10,6 +10,7 @@ import { assertContractVariable } from '@eth-optimism/contracts-bedrock/src/depl
import
{
ethers
,
utils
}
from
'
ethers
'
import
type
{
DeployConfig
}
from
'
../../src
'
import
{
setupProxyContract
}
from
'
../../src/helpers/setupProxyContract
'
const
{
getAddress
}
=
utils
...
...
@@ -73,7 +74,7 @@ const deployFn: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
'
OptimistInviterProxy
'
)
console
.
log
(
`OptimistProxy deployed to
${
Deployment__OptimistInviterProxy
.
address
}
`
`Optimist
Inviter
Proxy deployed to
${
Deployment__OptimistInviterProxy
.
address
}
`
)
// Deployed Proxy.sol contract
...
...
@@ -88,79 +89,25 @@ const deployFn: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
Deployment__OptimistInviterProxy
.
address
)
// 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
// try to make a transaction if we don't use callStatic. Using the zero address as `from` lets us
// call functions on the proxy and not trigger the delegatecall. See Proxy.sol proxyCallIfNotAdmin
// modifier for more details.
const
implementation
=
await
Proxy
.
connect
(
ethers
.
constants
.
AddressZero
).
callStatic
.
implementation
()
console
.
log
(
`implementation set to
${
implementation
}
`
)
if
(
getAddress
(
implementation
)
!==
getAddress
(
Deployment__OptimistInviterImpl
.
address
)
)
{
// If the proxy isn't pointing to the correct implementation, we need to set it to the correct
// one, then call initialize() in the proxy's context.
console
.
log
(
'
implementation not set to OptimistInviter implementation contract
'
)
console
.
log
(
`Setting implementation to
${
Deployment__OptimistInviterImpl
.
address
}
`
)
const
name
=
deployConfig
.
optimistInviterName
// Create the calldata for the call to `initialize()`
const
calldata
=
OptimistInviter
.
interface
.
encodeFunctionData
(
'
initialize
'
,
[
name
]
)
// ethers.Signer for the ddd
const
dddSigner
=
await
hre
.
ethers
.
provider
.
getSigner
(
deployer
)
// Point the proxy to the deployed OptimistInviter implementation contract,
// and call `initialize()` in the proxy's context
const
tx
=
await
Proxy
.
connect
(
dddSigner
).
upgradeToAndCall
(
Deployment__OptimistInviterImpl
.
address
,
calldata
)
const
receipt
=
await
tx
.
wait
()
console
.
log
(
`implementation set in
${
receipt
.
transactionHash
}
`
)
}
else
{
console
.
log
(
'
implementation already set to OptimistInviter implementation contract
'
)
}
const
l2ProxyOwnerAddress
=
deployConfig
.
l2ProxyOwnerAddress
// Get the current proxy admin address
const
admin
=
await
Proxy
.
connect
(
ethers
.
constants
.
AddressZero
).
callStatic
.
admin
()
console
.
log
(
`admin currently set to
${
admin
}
`
)
const
name
=
deployConfig
.
optimistInviterName
// Create the calldata for the call to `initialize()`
const
initializeCalldata
=
OptimistInviter
.
interface
.
encodeFunctionData
(
'
initialize
'
,
[
name
]
)
if
(
getAddress
(
admin
)
!==
getAddress
(
l2ProxyOwnerAddress
))
{
// If the proxy admin isn't the l2ProxyOwnerAddress, we need to update it
// We're assuming that the proxy admin is the ddd right now.
console
.
log
(
'
admin is not set to the l2ProxyOwnerAddress
'
)
console
.
log
(
`Setting admin to
${
l2ProxyOwnerAddress
}
`
)
// ethers.Signer for the ddd. Should be the current owner of the Proxy.
const
dddSigner
=
await
hre
.
ethers
.
provider
.
getSigner
(
deployer
)
// ethers.Signer for the ddd
const
dddSigner
=
await
hre
.
ethers
.
provider
.
getSigner
(
deployer
)
// intended admin of the Proxy
const
l2ProxyOwnerAddress
=
deployConfig
.
l2ProxyOwnerAddress
// change admin to the l2ProxyOwnerAddress
const
tx
=
await
Proxy
.
connect
(
dddSigner
).
changeAdmin
(
l2ProxyOwnerAddress
)
const
receipt
=
await
tx
.
wait
()
console
.
log
(
`admin set in
${
receipt
.
transactionHash
}
`
)
}
else
{
console
.
log
(
'
admin already set to proxy owner address
'
)
}
// setup the Proxy contract with correct implementation and admin
await
setupProxyContract
(
Proxy
,
dddSigner
,
{
targetImplAddress
:
Deployment__OptimistInviterImpl
.
address
,
targetProxyOwnerAddress
:
l2ProxyOwnerAddress
,
postUpgradeCallCalldata
:
initializeCalldata
,
})
const
Deployment__AttestationStation
=
await
hre
.
deployments
.
get
(
'
AttestationStationProxy
'
...
...
@@ -190,6 +137,6 @@ const deployFn: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
}
deployFn
.
tags
=
[
'
OptimistInviterProxy
'
,
'
OptimistEnvironment
'
]
deployFn
.
dependencies
=
[
'
AttestationStationProxy
'
,
'
OptimistInviter
'
]
deployFn
.
dependencies
=
[
'
AttestationStationProxy
'
,
'
OptimistInviter
Impl
'
]
export
default
deployFn
packages/contracts-periphery/deploy/op-nft/OptimistProxy.ts
View file @
b1e9c0e2
...
...
@@ -5,8 +5,9 @@ import '@eth-optimism/hardhat-deploy-config'
import
'
@nomiclabs/hardhat-ethers
'
import
'
hardhat-deploy
'
import
{
assertContractVariable
}
from
'
@eth-optimism/contracts-bedrock/src/deploy-utils
'
import
{
ethers
,
utils
}
from
'
ethers
'
import
{
utils
}
from
'
ethers
'
import
{
setupProxyContract
}
from
'
../../src/helpers/setupProxyContract
'
import
type
{
DeployConfig
}
from
'
../../src
'
const
{
getAddress
}
=
utils
...
...
@@ -21,7 +22,7 @@ const deployFn: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
throw
new
Error
(
'
Must deploy with the ddd
'
)
}
const
Deployment__Optimist
=
await
hre
.
deployments
.
get
(
'
Optimist
'
)
const
Deployment__Optimist
Impl
=
await
hre
.
deployments
.
get
(
'
Optimist
'
)
console
.
log
(
`Deploying OptimistProxy with
${
deployer
}
`
)
...
...
@@ -48,69 +49,58 @@ const deployFn: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
Deployment__OptimistProxy
.
address
)
const
implementation
=
await
Proxy
.
connect
(
ethers
.
constants
.
AddressZero
).
callStatic
.
implementation
()
console
.
log
(
`implementation set to
${
implementation
}
`
)
if
(
getAddress
(
implementation
)
!==
getAddress
(
Deployment__Optimist
.
address
))
{
console
.
log
(
'
implementation not set to Optimist contract
'
)
console
.
log
(
`Setting implementation to
${
Deployment__Optimist
.
address
}
`
)
// Create the calldata for the call to `initialize()`
const
name
=
deployConfig
.
optimistName
const
symbol
=
deployConfig
.
optimistSymbol
const
calldata
=
Optimist
.
interface
.
encodeFunctionData
(
'
initialize
'
,
[
name
,
symbol
,
])
const
tx
=
await
Proxy
.
upgradeToAndCall
(
Deployment__Optimist
.
address
,
calldata
)
const
receipt
=
await
tx
.
wait
()
console
.
log
(
`implementation set in
${
receipt
.
transactionHash
}
`
)
}
else
{
console
.
log
(
'
implementation already set to Optimist contract
'
)
}
// ethers.Signer for the ddd. Should be the current owner of the Proxy.
const
dddSigner
=
await
hre
.
ethers
.
provider
.
getSigner
(
deployer
)
// intended admin of the Proxy
const
l2ProxyOwnerAddress
=
deployConfig
.
l2ProxyOwnerAddress
const
admin
=
await
Proxy
.
connect
(
ethers
.
constants
.
AddressZero
).
callStatic
.
admin
()
console
.
log
(
`admin set to
${
admin
}
`
)
if
(
getAddress
(
admin
)
!==
getAddress
(
l2ProxyOwnerAddress
))
{
console
.
log
(
'
detected admin is not set
'
)
console
.
log
(
`Setting admin to
${
l2ProxyOwnerAddress
}
`
)
const
tx
=
await
Proxy
.
changeAdmin
(
l2ProxyOwnerAddress
)
const
receipt
=
await
tx
.
wait
()
console
.
log
(
`admin set in
${
receipt
.
transactionHash
}
`
)
}
else
{
console
.
log
(
'
admin already set to proxy owner address
'
)
}
const
Deployment__AttestationStation
=
await
hre
.
deployments
.
get
(
// Create the calldata for the call to `initialize()`
const
name
=
deployConfig
.
optimistName
const
symbol
=
deployConfig
.
optimistSymbol
const
initializeCalldata
=
Optimist
.
interface
.
encodeFunctionData
(
'
initialize
'
,
[
name
,
symbol
]
)
// setup the Proxy contract with correct implementation and admin, and initialize atomically
await
setupProxyContract
(
Proxy
,
dddSigner
,
{
targetImplAddress
:
Deployment__OptimistImpl
.
address
,
targetProxyOwnerAddress
:
l2ProxyOwnerAddress
,
postUpgradeCallCalldata
:
initializeCalldata
,
})
const
Deployment__AttestationStationProxy
=
await
hre
.
deployments
.
get
(
'
AttestationStationProxy
'
)
const
Deployment__OptimistAllowlistProxy
=
await
hre
.
deployments
.
get
(
'
OptimistAllowlistProxy
'
)
await
assertContractVariable
(
Proxy
,
'
admin
'
,
l2ProxyOwnerAddress
)
await
assertContractVariable
(
Optimist
,
'
name
'
,
deployConfig
.
optimistName
)
await
assertContractVariable
(
Optimist
,
'
version
'
,
'
1
.0.0
'
)
await
assertContractVariable
(
Optimist
,
'
version
'
,
'
2
.0.0
'
)
await
assertContractVariable
(
Optimist
,
'
symbol
'
,
deployConfig
.
optimistSymbol
)
await
assertContractVariable
(
Optimist
,
'
ATTESTOR
'
,
deployConfig
.
attestorAddress
'
BASE_URI_ATTESTOR
'
,
deployConfig
.
optimistBaseUriAttestorAddress
)
await
assertContractVariable
(
Optimist
,
'
OPTIMIST_ALLOWLIST
'
,
Deployment__OptimistAllowlistProxy
.
address
)
await
assertContractVariable
(
Optimist
,
'
ATTESTATION_STATION
'
,
Deployment__AttestationStation
.
address
Deployment__AttestationStation
Proxy
.
address
)
}
deployFn
.
tags
=
[
'
OptimistProxy
'
,
'
OptimistEnvironment
'
]
deployFn
.
dependencies
=
[
'
AttestationStationProxy
'
,
'
Optimist
'
]
deployFn
.
dependencies
=
[
'
AttestationStationProxy
'
,
'
Optimist
Impl
'
]
export
default
deployFn
packages/contracts-periphery/src/config/deploy.ts
View file @
b1e9c0e2
...
...
@@ -31,7 +31,7 @@ export interface DeployConfig {
/**
* Address of the privileged attestor for the Optimist contract.
*/
a
ttestorAddress
:
string
optimistBaseUriA
ttestorAddress
:
string
/**
* Address of the privileged account for the OptimistInviter contract that can grant invites.
...
...
@@ -43,6 +43,17 @@ export interface DeployConfig {
*/
optimistInviterName
:
string
/**
* Address of previleged account for the OptimistAllowlist contract that can add/remove people
* from allowlist.
*/
optimistAllowlistAllowlistAttestor
:
string
/**
* Address of Coinbase attestor that attests to whether someone has completed Quest.
*/
optimistAllowlistCoinbaseQuestAttestor
:
string
/**
* Address of the owner of the proxies on L2. There will be a ProxyAdmin deployed as a predeploy
* after bedrock, so the owner of proxies should be updated to that after the upgrade.
...
...
@@ -70,7 +81,7 @@ export const configSpec: DeployConfigSpec<DeployConfig> = {
type
:
'
string
'
,
default
:
'
OPTIMIST
'
,
},
a
ttestorAddress
:
{
optimistBaseUriA
ttestorAddress
:
{
type
:
'
address
'
,
},
optimistInviterInviteGranter
:
{
...
...
@@ -79,6 +90,15 @@ export const configSpec: DeployConfigSpec<DeployConfig> = {
optimistInviterName
:
{
type
:
'
string
'
,
},
optimistAllowlistAllowlistAttestor
:
{
type
:
'
address
'
,
},
optimistAllowlistCoinbaseQuestAttestor
:
{
type
:
'
address
'
,
},
l2ProxyOwnerAddress
:
{
type
:
'
address
'
,
},
...
...
packages/contracts-periphery/src/helpers/setupProxyContract.ts
0 → 100644
View file @
b1e9c0e2
import
assert
from
'
assert
'
import
{
ethers
,
utils
}
from
'
ethers
'
const
{
getAddress
}
=
utils
type
ProxyConfig
=
{
targetImplAddress
:
string
targetProxyOwnerAddress
:
string
postUpgradeCallCalldata
?:
string
}
// Sets up the newly deployed proxy contract such that:
// 1. The proxy's implementation is set to the target implementation
// 2. The proxy's admin is set to the target proxy owner
//
// If the values are set correctly already, it makes no transactions.
const
setupProxyContract
=
async
(
proxyContract
:
ethers
.
Contract
,
proxyOwnerSigner
:
ethers
.
Signer
,
{
targetImplAddress
,
targetProxyOwnerAddress
,
postUpgradeCallCalldata
,
}:
ProxyConfig
)
=>
{
const
currentAdmin
=
await
proxyContract
.
connect
(
ethers
.
constants
.
AddressZero
)
.
callStatic
.
admin
()
// The proxy owner signer needs to be the current admin, otherwise we don't have permission
// 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.
// callStatic is used since the `Proxy.implementation()` is not a view function and ethers will
// try to make a transaction if we don't use callStatic. Using the zero address as `from` lets us
// call functions on the proxy and not trigger the delegatecall. See Proxy.sol proxyCallIfNotAdmin
// modifier for more details.
const
currentImplementation
=
await
proxyContract
.
connect
(
ethers
.
constants
.
AddressZero
)
.
callStatic
.
implementation
()
console
.
log
(
`implementation currently set to
${
currentImplementation
}
`
)
if
(
getAddress
(
currentImplementation
)
!==
getAddress
(
targetImplAddress
))
{
// If the proxy isn't pointing to the correct implementation, we need to set it to the correct
// one, then call initialize() in the proxy's context.
console
.
log
(
'
implementation not set to correct contract
'
)
console
.
log
(
`Setting implementation to
${
targetImplAddress
}
`
)
let
tx
:
ethers
.
providers
.
TransactionResponse
if
(
!
postUpgradeCallCalldata
)
{
console
.
log
(
'
postUpgradeCallCalldata is not provided. Using Proxy.upgrade()
'
)
// Point the proxy to the target implementation
tx
=
await
proxyContract
.
connect
(
proxyOwnerSigner
)
.
upgradeTo
(
targetImplAddress
)
}
else
{
console
.
log
(
'
postUpgradeCallCalldata is provided. Using Proxy.upgradeAndCall()
'
)
// Point the proxy to the target implementation,
// and call function in the proxy's context
tx
=
await
proxyContract
.
connect
(
proxyOwnerSigner
)
.
upgradeToAndCall
(
targetImplAddress
,
postUpgradeCallCalldata
)
}
const
receipt
=
await
tx
.
wait
()
console
.
log
(
`implementation set in
${
receipt
.
transactionHash
}
`
)
}
else
{
console
.
log
(
`implementation already set correctly to
${
targetImplAddress
}
`
)
}
console
.
log
(
`admin set to
${
currentAdmin
}
`
)
if
(
getAddress
(
currentAdmin
)
!==
getAddress
(
targetProxyOwnerAddress
))
{
// If the proxy admin isn't the l2ProxyOwnerAddress, we need to update it
// We're assuming that the proxy admin is the ddd right now.
console
.
log
(
'
detected admin is not set correctly
'
)
console
.
log
(
`Setting admin to
${
targetProxyOwnerAddress
}
`
)
// change admin to the l2ProxyOwnerAddress
const
tx
=
await
proxyContract
.
connect
(
proxyOwnerSigner
)
.
changeAdmin
(
targetProxyOwnerAddress
)
const
receipt
=
await
tx
.
wait
()
console
.
log
(
`admin set in
${
receipt
.
transactionHash
}
`
)
}
else
{
console
.
log
(
`admin already set correctly to
${
targetProxyOwnerAddress
}
`
)
}
const
updatedImplementation
=
await
proxyContract
.
connect
(
ethers
.
constants
.
AddressZero
)
.
callStatic
.
implementation
()
const
updatedAdmin
=
await
proxyContract
.
connect
(
ethers
.
constants
.
AddressZero
)
.
callStatic
.
admin
()
assert
(
getAddress
(
updatedAdmin
)
===
getAddress
(
targetProxyOwnerAddress
),
'
Something went wrong - admin not set correctly after transaction
'
)
assert
(
getAddress
(
updatedImplementation
)
===
getAddress
(
targetImplAddress
),
'
Something went wrong - implementation not set correctly after transaction
'
)
console
.
log
(
`Proxy at
${
proxyContract
.
address
}
is set up with implementation:
${
updatedImplementation
}
and admin:
${
updatedAdmin
}
`
)
}
export
{
setupProxyContract
}
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