forked from ethereum-optimism/optimism
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'integration' into espresso-demo-setup
- Loading branch information
Showing
10 changed files
with
144 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { task, types } from 'hardhat/config' | ||
import { providers, utils } from 'ethers' | ||
import fetch from 'node-fetch' | ||
|
||
const GRANT_AMOUNT = utils.parseEther('0.1') | ||
|
||
task('faucet-request', 'Deposits WETH9 onto L2.') | ||
.addParam( | ||
'l2ProviderUrl', | ||
'L2 provider URL.', | ||
'http://localhost:9545', | ||
types.string | ||
) | ||
.addParam( | ||
'faucetUrl', | ||
'L2 faucet URL', | ||
'http://localhost:18111', | ||
types.string | ||
) | ||
.setAction(async (args, hre) => { | ||
const signers = await hre.ethers.getSigners() | ||
if (signers.length === 0) { | ||
throw new Error('No configured signers') | ||
} | ||
// Use the last configured signer so we don't conflict with some other task | ||
const provider = new providers.StaticJsonRpcProvider(args.l2ProviderUrl) | ||
const signer = new hre.ethers.Wallet( | ||
hre.network.config.accounts[0], | ||
provider | ||
) | ||
const address = await signer.getAddress() | ||
console.log(`Using signer ${address}`) | ||
|
||
// Check the signer's balance before we do anything | ||
const initialBalance = await signer.getBalance() | ||
console.log(`Signer initial balance is ${initialBalance}`) | ||
|
||
// Request from the faucet | ||
const res = await fetch(`${args.faucetUrl}/faucet/request/${address}`, { | ||
method: 'POST', | ||
}) | ||
if (res.status !== 200) { | ||
throw new Error(`Request failed with status ${res.status}`) | ||
} | ||
|
||
// Wait for our balance to increase. | ||
for (;;) { | ||
const balance = await signer.getBalance() | ||
console.log(`Signer balance is ${balance}`) | ||
if (balance >= initialBalance + GRANT_AMOUNT) { | ||
break | ||
} | ||
await new Promise((resolve) => setTimeout(resolve, 1000)) | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import './deploy-erc20' | ||
import './deposit-eth' | ||
import './deposit-erc20' | ||
import './faucet-request' | ||
import './finalize-withdrawal' |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.