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
49fdd592
Unverified
Commit
49fdd592
authored
Jan 08, 2023
by
Matthew Slipper
Committed by
GitHub
Jan 08, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4630 from ethereum-optimism/feat/enable-eth-deposit-withdraw
sdk: allow `deposit-eth` task to work with artifacts
parents
f9b891fe
ae8e046f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
85 additions
and
9 deletions
+85
-9
hardhat.config.ts
packages/sdk/hardhat.config.ts
+11
-0
deposit-eth.ts
packages/sdk/tasks/deposit-eth.ts
+74
-9
No files found.
packages/sdk/hardhat.config.ts
View file @
49fdd592
...
@@ -29,6 +29,12 @@ const config: HardhatUserConfig = {
...
@@ -29,6 +29,12 @@ const config: HardhatUserConfig = {
url
:
process
.
env
.
L1_RPC
||
''
,
url
:
process
.
env
.
L1_RPC
||
''
,
accounts
:
[
process
.
env
.
PRIVATE_KEY_DEPLOYER
||
ethers
.
constants
.
HashZero
],
accounts
:
[
process
.
env
.
PRIVATE_KEY_DEPLOYER
||
ethers
.
constants
.
HashZero
],
},
},
'
final-migration-rehearsal
'
:
{
chainId
:
5
,
url
:
process
.
env
.
L1_RPC
||
''
,
accounts
:
[
process
.
env
.
PRIVATE_KEY_DEPLOYER
||
ethers
.
constants
.
HashZero
],
live
:
true
,
},
},
},
external
:
{
external
:
{
contracts
:
[
contracts
:
[
...
@@ -43,6 +49,11 @@ const config: HardhatUserConfig = {
...
@@ -43,6 +49,11 @@ const config: HardhatUserConfig = {
'
../contracts-bedrock/deployments/goerli
'
,
'
../contracts-bedrock/deployments/goerli
'
,
'
../contracts/deployments/goerli
'
,
'
../contracts/deployments/goerli
'
,
],
],
'
final-migration-rehearsal
'
:
[
'
../contracts-bedrock/deployments/final-migration-rehearsal
'
,
'
../contracts/deployments/goerli
'
,
'
../contracts-periphery/deployments/goerli
'
,
],
},
},
},
},
}
}
...
...
packages/sdk/tasks/deposit-eth.ts
View file @
49fdd592
...
@@ -3,11 +3,12 @@ import { promises as fs } from 'fs'
...
@@ -3,11 +3,12 @@ import { promises as fs } from 'fs'
import
{
task
,
types
}
from
'
hardhat/config
'
import
{
task
,
types
}
from
'
hardhat/config
'
import
'
@nomiclabs/hardhat-ethers
'
import
'
@nomiclabs/hardhat-ethers
'
import
'
hardhat-deploy
'
import
'
hardhat-deploy
'
import
{
Deployment
}
from
'
hardhat-deploy/types
'
import
{
import
{
predeploys
,
predeploys
,
getContractDefinition
,
getContractDefinition
,
}
from
'
@eth-optimism/contracts-bedrock
'
}
from
'
@eth-optimism/contracts-bedrock
'
import
{
providers
,
utils
}
from
'
ethers
'
import
{
providers
,
utils
,
ethers
}
from
'
ethers
'
import
{
import
{
CrossChainMessenger
,
CrossChainMessenger
,
...
@@ -17,7 +18,7 @@ import {
...
@@ -17,7 +18,7 @@ import {
DEFAULT_L2_CONTRACT_ADDRESSES
,
DEFAULT_L2_CONTRACT_ADDRESSES
,
}
from
'
../src
'
}
from
'
../src
'
task
(
'
deposit-eth
'
,
'
Deposits
WETH9 on
to L2.
'
)
task
(
'
deposit-eth
'
,
'
Deposits
ether
to L2.
'
)
.
addParam
(
.
addParam
(
'
l2ProviderUrl
'
,
'
l2ProviderUrl
'
,
'
L2 provider URL.
'
,
'
L2 provider URL.
'
,
...
@@ -66,6 +67,7 @@ task('deposit-eth', 'Deposits WETH9 onto L2.')
...
@@ -66,6 +67,7 @@ task('deposit-eth', 'Deposits WETH9 onto L2.')
if
(
balance
.
eq
(
0
))
{
if
(
balance
.
eq
(
0
))
{
throw
new
Error
(
'
Signer has no balance
'
)
throw
new
Error
(
'
Signer has no balance
'
)
}
}
console
.
log
(
`Signer balance:
${
utils
.
formatEther
(
balance
.
toString
())}
`
)
const
l2Provider
=
new
providers
.
StaticJsonRpcProvider
(
args
.
l2ProviderUrl
)
const
l2Provider
=
new
providers
.
StaticJsonRpcProvider
(
args
.
l2ProviderUrl
)
...
@@ -91,6 +93,57 @@ task('deposit-eth', 'Deposits WETH9 onto L2.')
...
@@ -91,6 +93,57 @@ task('deposit-eth', 'Deposits WETH9 onto L2.')
l1
:
JSON
.
parse
(
data
.
toString
()),
l1
:
JSON
.
parse
(
data
.
toString
()),
l2
:
DEFAULT_L2_CONTRACT_ADDRESSES
,
l2
:
DEFAULT_L2_CONTRACT_ADDRESSES
,
}
as
OEContractsLike
}
as
OEContractsLike
}
else
if
(
!
contractAddrs
)
{
// If the contract addresses have not been hardcoded,
// attempt to read them from deployment artifacts
let
Deployment__AddressManager
:
Deployment
try
{
Deployment__AddressManager
=
await
hre
.
deployments
.
get
(
'
AddressManager
'
)
}
catch
(
e
)
{
Deployment__AddressManager
=
await
hre
.
deployments
.
get
(
'
Lib_AddressManager
'
)
}
let
Deployment__L1CrossDomainMessenger
:
Deployment
try
{
Deployment__L1CrossDomainMessenger
=
await
hre
.
deployments
.
get
(
'
L1CrossDomainMessengerProxy
'
)
}
catch
(
e
)
{
Deployment__L1CrossDomainMessenger
=
await
hre
.
deployments
.
get
(
'
Proxy__OVM_L1CrossDomainMessenger
'
)
}
let
Deployment__L1StandardBridge
:
Deployment
try
{
Deployment__L1StandardBridge
=
await
hre
.
deployments
.
get
(
'
L1StandardBridgeProxy
'
)
}
catch
(
e
)
{
Deployment__L1StandardBridge
=
await
hre
.
deployments
.
get
(
'
Proxy__OVM_L1StandardBridge
'
)
}
const
Deployment__OptimismPortal
=
await
hre
.
deployments
.
get
(
'
OptimismPortalProxy
'
)
const
Deployment__L2OutputOracle
=
await
hre
.
deployments
.
get
(
'
L2OutputOracleProxy
'
)
contractAddrs
=
{
l1
:
{
AddressManager
:
Deployment__AddressManager
.
address
,
L1CrossDomainMessenger
:
Deployment__L1CrossDomainMessenger
,
L1StandardBridge
:
Deployment__L1StandardBridge
,
StateCommitmentChain
:
ethers
.
constants
.
AddressZero
,
CanonicalTransactionChain
:
ethers
.
constants
.
AddressZero
,
BondManager
:
ethers
.
constants
.
AddressZero
,
OptimismPortal
:
Deployment__OptimismPortal
.
address
,
L2OutputOracle
:
Deployment__L2OutputOracle
.
address
,
},
l2
:
DEFAULT_L2_CONTRACT_ADDRESSES
,
}
}
}
const
Artifact__L2ToL1MessagePasser
=
await
getContractDefinition
(
const
Artifact__L2ToL1MessagePasser
=
await
getContractDefinition
(
...
@@ -166,6 +219,7 @@ task('deposit-eth', 'Deposits WETH9 onto L2.')
...
@@ -166,6 +219,7 @@ task('deposit-eth', 'Deposits WETH9 onto L2.')
// Deposit ETH
// Deposit ETH
console
.
log
(
'
Depositing ETH through StandardBridge
'
)
console
.
log
(
'
Depositing ETH through StandardBridge
'
)
const
ethDeposit
=
await
messenger
.
depositETH
(
amount
,
{
recipient
:
to
})
const
ethDeposit
=
await
messenger
.
depositETH
(
amount
,
{
recipient
:
to
})
console
.
log
(
`Transaction hash:
${
ethDeposit
.
hash
}
`
)
const
depositMessageReceipt
=
await
messenger
.
waitForMessageReceipt
(
const
depositMessageReceipt
=
await
messenger
.
waitForMessageReceipt
(
ethDeposit
ethDeposit
)
)
...
@@ -173,7 +227,7 @@ task('deposit-eth', 'Deposits WETH9 onto L2.')
...
@@ -173,7 +227,7 @@ task('deposit-eth', 'Deposits WETH9 onto L2.')
throw
new
Error
(
'
deposit failed
'
)
throw
new
Error
(
'
deposit failed
'
)
}
}
console
.
log
(
console
.
log
(
`Deposit complete -
${
depositMessageReceipt
.
transactionReceipt
.
transactionHash
}
`
`Deposit complete -
included in block
${
depositMessageReceipt
.
transactionReceipt
.
blockNumber
}
`
)
)
const
opBalanceAfter
=
await
signer
.
provider
.
getBalance
(
const
opBalanceAfter
=
await
signer
.
provider
.
getBalance
(
...
@@ -184,14 +238,24 @@ task('deposit-eth', 'Deposits WETH9 onto L2.')
...
@@ -184,14 +238,24 @@ task('deposit-eth', 'Deposits WETH9 onto L2.')
throw
new
Error
(
`OptimismPortal balance mismatch`
)
throw
new
Error
(
`OptimismPortal balance mismatch`
)
}
}
const
l2Balance
=
await
l2Provider
.
getBalance
(
to
)
console
.
log
(
`L2 balance of deposit recipient:
${
utils
.
formatEther
(
l2Balance
.
toString
()
)}
`
)
if
(
!
args
.
withdraw
)
{
if
(
!
args
.
withdraw
)
{
return
return
}
}
console
.
log
(
'
Withdrawing ETH
'
)
console
.
log
(
'
Withdrawing ETH
'
)
const
ethWithdraw
=
await
messenger
.
withdrawETH
(
withdrawAmount
)
const
ethWithdraw
=
await
messenger
.
withdrawETH
(
withdrawAmount
)
console
.
log
(
`Transaction hash:
${
ethWithdraw
.
hash
}
`
)
const
ethWithdrawReceipt
=
await
ethWithdraw
.
wait
()
const
ethWithdrawReceipt
=
await
ethWithdraw
.
wait
()
console
.
log
(
`ETH withdrawn on L2 -
${
ethWithdrawReceipt
.
transactionHash
}
`
)
console
.
log
(
`ETH withdrawn on L2 - included in block
${
ethWithdrawReceipt
.
blockNumber
}
`
)
{
{
// check the logs
// check the logs
...
@@ -225,11 +289,8 @@ task('deposit-eth', 'Deposits WETH9 onto L2.')
...
@@ -225,11 +289,8 @@ task('deposit-eth', 'Deposits WETH9 onto L2.')
}
}
}
}
console
.
log
(
`Withdrawal on L2 complete:
${
ethWithdrawReceipt
.
transactionHash
}
`
)
console
.
log
(
'
Waiting to be able to prove withdrawal
'
)
console
.
log
(
'
Waiting to be able to prove withdrawal
'
)
const
proveInterval
=
setInterval
(
async
()
=>
{
const
proveInterval
=
setInterval
(
async
()
=>
{
const
currentStatus
=
await
messenger
.
getMessageStatus
(
ethWithdrawReceipt
)
const
currentStatus
=
await
messenger
.
getMessageStatus
(
ethWithdrawReceipt
)
console
.
log
(
`Message status:
${
MessageStatus
[
currentStatus
]}
`
)
console
.
log
(
`Message status:
${
MessageStatus
[
currentStatus
]}
`
)
...
@@ -246,12 +307,15 @@ task('deposit-eth', 'Deposits WETH9 onto L2.')
...
@@ -246,12 +307,15 @@ task('deposit-eth', 'Deposits WETH9 onto L2.')
console
.
log
(
'
Proving eth withdrawal...
'
)
console
.
log
(
'
Proving eth withdrawal...
'
)
const
ethProve
=
await
messenger
.
proveMessage
(
ethWithdrawReceipt
)
const
ethProve
=
await
messenger
.
proveMessage
(
ethWithdrawReceipt
)
console
.
log
(
`Transaction hash:
${
ethProve
.
hash
}
`
)
const
ethProveReceipt
=
await
ethProve
.
wait
()
const
ethProveReceipt
=
await
ethProve
.
wait
()
if
(
ethProveReceipt
.
status
!==
1
)
{
if
(
ethProveReceipt
.
status
!==
1
)
{
throw
new
Error
(
'
Prove withdrawal transaction reverted
'
)
throw
new
Error
(
'
Prove withdrawal transaction reverted
'
)
}
}
console
.
log
(
'
Successfully proved withdrawal
'
)
console
.
log
(
'
Waiting to be able to finalize withdrawal
'
)
console
.
log
(
'
Waiting to be able to finalize withdrawal
'
)
const
finalizeInterval
=
setInterval
(
async
()
=>
{
const
finalizeInterval
=
setInterval
(
async
()
=>
{
const
currentStatus
=
await
messenger
.
getMessageStatus
(
ethWithdrawReceipt
)
const
currentStatus
=
await
messenger
.
getMessageStatus
(
ethWithdrawReceipt
)
console
.
log
(
`Message status:
${
MessageStatus
[
currentStatus
]}
`
)
console
.
log
(
`Message status:
${
MessageStatus
[
currentStatus
]}
`
)
...
@@ -268,13 +332,14 @@ task('deposit-eth', 'Deposits WETH9 onto L2.')
...
@@ -268,13 +332,14 @@ task('deposit-eth', 'Deposits WETH9 onto L2.')
console
.
log
(
'
Finalizing eth withdrawal...
'
)
console
.
log
(
'
Finalizing eth withdrawal...
'
)
const
ethFinalize
=
await
messenger
.
finalizeMessage
(
ethWithdrawReceipt
)
const
ethFinalize
=
await
messenger
.
finalizeMessage
(
ethWithdrawReceipt
)
console
.
log
(
`Transaction hash:
${
ethFinalize
.
hash
}
`
)
const
ethFinalizeReceipt
=
await
ethFinalize
.
wait
()
const
ethFinalizeReceipt
=
await
ethFinalize
.
wait
()
if
(
ethFinalizeReceipt
.
status
!==
1
)
{
if
(
ethFinalizeReceipt
.
status
!==
1
)
{
throw
new
Error
(
'
Finalize withdrawal reverted
'
)
throw
new
Error
(
'
Finalize withdrawal reverted
'
)
}
}
console
.
log
(
console
.
log
(
`ETH withdrawal complete
:
${
ethFinalizeReceipt
.
transactionHash
}
`
`ETH withdrawal complete
- included in block
${
ethFinalizeReceipt
.
blockNumber
}
`
)
)
{
{
// Check that the logs are correct
// Check that the logs are correct
...
...
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