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
c081652e
Unverified
Commit
c081652e
authored
Aug 04, 2021
by
Mark Tyneway
Committed by
GitHub
Aug 04, 2021
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1310 from ethereum-optimism/feat/whitelist-hardhat-task
contracts: add hardhat task for whitelisting addresses
parents
01679a41
7f26667d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
94 additions
and
0 deletions
+94
-0
popular-carpets-applaud.md
.changeset/popular-carpets-applaud.md
+5
-0
hardhat.config.ts
packages/contracts/hardhat.config.ts
+1
-0
whitelist.ts
packages/contracts/tasks/whitelist.ts
+88
-0
No files found.
.changeset/popular-carpets-applaud.md
0 → 100644
View file @
c081652e
---
'
@eth-optimism/contracts'
:
patch
---
Add hardhat task for whitelisting addresses
packages/contracts/hardhat.config.ts
View file @
c081652e
...
@@ -16,6 +16,7 @@ import '@eth-optimism/hardhat-ovm'
...
@@ -16,6 +16,7 @@ import '@eth-optimism/hardhat-ovm'
import
'
./tasks/deploy
'
import
'
./tasks/deploy
'
import
'
./tasks/l2-gasprice
'
import
'
./tasks/l2-gasprice
'
import
'
./tasks/set-owner
'
import
'
./tasks/set-owner
'
import
'
./tasks/whitelist
'
import
'
hardhat-gas-reporter
'
import
'
hardhat-gas-reporter
'
// Load environment variables from .env
// Load environment variables from .env
...
...
packages/contracts/tasks/whitelist.ts
0 → 100644
View file @
c081652e
'
use strict
'
import
{
ethers
}
from
'
ethers
'
import
{
task
}
from
'
hardhat/config
'
import
*
as
types
from
'
hardhat/internal/core/params/argumentTypes
'
import
{
LedgerSigner
}
from
'
@ethersproject/hardware-wallets
'
import
{
getContractFactory
}
from
'
../src/contract-defs
'
import
{
predeploys
}
from
'
../src/predeploys
'
// Add accounts the the OVM_DeployerWhitelist
// npx hardhat whitelist --address 0x..
task
(
'
whitelist
'
)
.
addParam
(
'
address
'
,
'
Address to whitelist
'
,
undefined
,
types
.
string
)
.
addOptionalParam
(
'
transactionGasPrice
'
,
'
tx.gasPrice
'
,
undefined
,
types
.
int
)
.
addOptionalParam
(
'
useLedger
'
,
'
use a ledger for signing
'
,
false
,
types
.
boolean
)
.
addOptionalParam
(
'
ledgerPath
'
,
'
ledger key derivation path
'
,
ethers
.
utils
.
defaultPath
,
types
.
string
)
.
addOptionalParam
(
'
contractsRpcUrl
'
,
'
Sequencer HTTP Endpoint
'
,
process
.
env
.
CONTRACTS_RPC_URL
,
types
.
string
)
.
addOptionalParam
(
'
contractsDeployerKey
'
,
'
Private Key
'
,
process
.
env
.
CONTRACTS_DEPLOYER_KEY
,
types
.
string
)
.
addOptionalParam
(
'
contractAddress
'
,
'
Address of Ownable contract
'
,
predeploys
.
OVM_DeployerWhitelist
,
types
.
string
)
.
setAction
(
async
(
args
,
hre
:
any
)
=>
{
const
provider
=
new
ethers
.
providers
.
JsonRpcProvider
(
args
.
contractsRpcUrl
)
let
signer
:
ethers
.
Signer
if
(
!
args
.
useLedger
)
{
if
(
!
args
.
contractsDeployerKey
)
{
throw
new
Error
(
'
Must pass --contracts-deployer-key
'
)
}
signer
=
new
ethers
.
Wallet
(
args
.
contractsDeployerKey
).
connect
(
provider
)
}
else
{
signer
=
new
LedgerSigner
(
provider
,
'
default
'
,
args
.
ledgerPath
)
}
const
deployerWhitelist
=
getContractFactory
(
'
OVM_DeployerWhitelist
'
)
.
connect
(
signer
)
.
attach
(
args
.
contractAddress
)
const
addr
=
await
signer
.
getAddress
()
console
.
log
(
`Using signer:
${
addr
}
`
)
let
owner
=
await
deployerWhitelist
.
owner
()
console
.
log
(
`OVM_DeployerWhitelist owner:
${
owner
}
`
)
if
(
owner
===
'
0x0000000000000000000000000000000000000000
'
)
{
console
.
log
(
`Initializing whitelist`
)
const
response
=
await
deployerWhitelist
.
initialize
(
addr
,
false
,
{
gasPrice
:
args
.
transactionGasPrice
,
})
const
receipt
=
await
response
.
wait
()
console
.
log
(
`Initialized whitelist:
${
receipt
.
transactionHash
}
`
)
owner
=
await
deployerWhitelist
.
owner
()
}
if
(
addr
!==
owner
)
{
throw
new
Error
(
`Incorrect key. Owner
${
owner
}
, Signer
${
addr
}
`
)
}
const
res
=
await
deployerWhitelist
.
setWhitelistedDeployer
(
args
.
address
,
true
,
{
gasPrice
:
args
.
transactionGasPrice
}
)
await
res
.
wait
()
console
.
log
(
`Whitelisted
${
args
.
address
}
`
)
})
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