Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 6 additions & 13 deletions packages/contracts/deploy/016-fund-accounts.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
/* Imports: External */
import { sleep } from '@eth-optimism/core-utils'
import { DeployFunction } from 'hardhat-deploy/dist/types'
import { defaultHardhatNetworkHdAccountsConfigParams } from 'hardhat/internal/core/config/default-config'
import { normalizeHardhatNetworkAccountsConfig } from 'hardhat/internal/core/providers/util'

/* Imports: Internal */
import { getContractFromArtifact, isHardhatNode } from '../src/deploy-utils'
Expand All @@ -24,29 +22,24 @@ const deployFn: DeployFunction = async (hre) => {

// Default has 20 accounts but we restrict to 20 accounts manually as well just to prevent
// future problems if the number of default accounts increases for whatever reason.
const accounts = normalizeHardhatNetworkAccountsConfig(
defaultHardhatNetworkHdAccountsConfigParams
).slice(0, 20)
const signers = (await hre.ethers.getSigners()).slice(0, 20)

// Fund the accounts in parallel to speed things up.
await Promise.all(
accounts.map(async (account, index) => {
signers.map(async (signer, index) => {
// Add a sleep here to avoid any potential issues with spamming hardhat. Not sure if this
// is strictly necessary but it can't hurt.
await sleep(200 * index)

const wallet = new hre.ethers.Wallet(
account.privateKey,
hre.ethers.provider
)
const balance = await wallet.getBalance()
const balance = await signer.getBalance()
const depositAmount = balance.div(2) // Deposit half of the wallet's balance into L2.
await L1StandardBridge.connect(wallet).depositETH(8_000_000, '0x', {
await L1StandardBridge.connect(signer).depositETH(8_000_000, '0x', {
value: depositAmount,
gasLimit: 2_000_000, // Idk, gas estimation was broken and this fixes it.
})

console.log(
`✓ Funded ${wallet.address} on L2 with ${hre.ethers.utils.formatEther(
`✓ Funded ${signer.address} on L2 with ${hre.ethers.utils.formatEther(
depositAmount
)} ETH`
)
Expand Down