-
Notifications
You must be signed in to change notification settings - Fork 473
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(contracts): OZ-L2-M02 WETH9 Approval Can Be Front-Run (#632)
Co-authored-by: HAOYUatHZ <37070449+HAOYUatHZ@users.noreply.github.com>
- Loading branch information
Showing
5 changed files
with
66 additions
and
801 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,30 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.8.10; | ||
|
||
import { Script } from "forge-std/Script.sol"; | ||
import { console } from "forge-std/console.sol"; | ||
import {Script} from "forge-std/Script.sol"; | ||
import {console} from "forge-std/console.sol"; | ||
|
||
import { WETH9 } from "../../src/L2/predeploys/WETH9.sol"; | ||
import {WrappedEther} from "../../src/L2/predeploys/WrappedEther.sol"; | ||
|
||
contract DeployWeth is Script { | ||
address L1_WETH_ADDR = vm.envAddress("L1_WETH_ADDR"); | ||
address L2_WETH_ADDR = vm.envAddress("L2_WETH_ADDR"); | ||
address L1_WETH_ADDR = vm.envAddress("L1_WETH_ADDR"); | ||
address L2_WETH_ADDR = vm.envAddress("L2_WETH_ADDR"); | ||
|
||
function run() external { | ||
// deploy weth only if we're running a private L1 network | ||
if (L1_WETH_ADDR == address(0)) { | ||
uint256 L1_WETH_DEPLOYER_PRIVATE_KEY = vm.envUint("L1_WETH_DEPLOYER_PRIVATE_KEY"); | ||
vm.startBroadcast(L1_WETH_DEPLOYER_PRIVATE_KEY); | ||
WETH9 weth = new WETH9(); | ||
L1_WETH_ADDR = address(weth); | ||
vm.stopBroadcast(); | ||
} | ||
function run() external { | ||
// deploy weth only if we're running a private L1 network | ||
if (L1_WETH_ADDR == address(0)) { | ||
uint256 L1_WETH_DEPLOYER_PRIVATE_KEY = vm.envUint("L1_WETH_DEPLOYER_PRIVATE_KEY"); | ||
vm.startBroadcast(L1_WETH_DEPLOYER_PRIVATE_KEY); | ||
WrappedEther weth = new WrappedEther(); | ||
L1_WETH_ADDR = address(weth); | ||
vm.stopBroadcast(); | ||
} | ||
|
||
logAddress("L1_WETH_ADDR", L1_WETH_ADDR); | ||
logAddress("L2_WETH_ADDR", L2_WETH_ADDR); | ||
} | ||
logAddress("L1_WETH_ADDR", L1_WETH_ADDR); | ||
logAddress("L2_WETH_ADDR", L2_WETH_ADDR); | ||
} | ||
|
||
function logAddress(string memory name, address addr) internal view { | ||
console.log(string(abi.encodePacked(name, "=", vm.toString(address(addr))))); | ||
} | ||
function logAddress(string memory name, address addr) internal view { | ||
console.log(string(abi.encodePacked(name, "=", vm.toString(address(addr))))); | ||
} | ||
} |
Oops, something went wrong.