-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
113 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
pragma solidity 0.8.23; | ||
|
||
import { ERC1967Proxy } from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol"; | ||
import { Upgrades } from "openzeppelin-foundry-upgrades/Upgrades.sol"; | ||
import { Options } from "openzeppelin-foundry-upgrades/Options.sol"; | ||
import { Script, console2 } from "forge-std/Script.sol"; | ||
import { L2GovernorPaused } from "src/L2/paused/L2GovernorPaused.sol"; | ||
import "script/contracts/Utils.sol"; | ||
|
||
/// @title L2GovernorPausedScript - L2GovernorPaused contract deployment script | ||
/// @notice This contract is used to deploy L2GovernorPaused contract and write its address to JSON file. | ||
contract L2GovernorPausedScript is Script { | ||
/// @notice Utils contract which provides functions to read and write JSON files containing L1 and L2 addresses. | ||
Utils utils; | ||
|
||
function setUp() public { | ||
utils = new Utils(); | ||
} | ||
|
||
/// @notice This function deploys L2GovernorPaused contract and writes its address to JSON file. | ||
function run() public { | ||
// Deployer's private key. This key is used to deploy the contract. | ||
uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY"); | ||
|
||
// Validate L2GovernorPaused contract if it is implemented correctly so that it may be used as new | ||
// implementation for the proxy contract. | ||
Options memory opts; | ||
opts.referenceContract = "L2Governor.sol"; | ||
opts.unsafeAllow = "constructor,external-library-linking"; | ||
Upgrades.validateUpgrade("L2GovernorPaused.sol", opts); | ||
|
||
console2.log("Deploying L2GovernorPaused contract..."); | ||
|
||
// deploy L2GovernorPaused contract | ||
vm.startBroadcast(deployerPrivateKey); | ||
L2GovernorPaused l2GovernorPaused = new L2GovernorPaused(); | ||
vm.stopBroadcast(); | ||
|
||
assert(address(l2GovernorPaused) != address(0)); | ||
|
||
// ERC1967Utils: keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1. | ||
assert(l2GovernorPaused.proxiableUUID() == bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1)); | ||
|
||
console2.log("L2GovernorPaused contract successfully deployed!"); | ||
console2.log("L2GovernorPaused (Implementation) address: %s", address(l2GovernorPaused)); | ||
|
||
// write L2GovernorPaused address to l2addresses.json | ||
Utils.L2AddressesConfig memory l2AddressesConfig = utils.readL2AddressesFile(); | ||
l2AddressesConfig.L2GovernorPaused = address(l2GovernorPaused); | ||
utils.writeL2AddressesFile(l2AddressesConfig); | ||
} | ||
} |
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,56 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
pragma solidity 0.8.23; | ||
|
||
import { ERC1967Proxy } from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol"; | ||
import { Upgrades } from "openzeppelin-foundry-upgrades/Upgrades.sol"; | ||
import { Options } from "openzeppelin-foundry-upgrades/Options.sol"; | ||
import { Script, console2 } from "forge-std/Script.sol"; | ||
import { L2VotingPowerPaused } from "src/L2/paused/L2VotingPowerPaused.sol"; | ||
import "script/contracts/Utils.sol"; | ||
|
||
/// @title L2VotingPowerPausedScript - L2VotingPowerPaused contract deployment script | ||
/// @notice This contract is used to deploy L2VotingPowerPaused contract and write its address to JSON file. | ||
contract L2VotingPowerPausedScript is Script { | ||
/// @notice Utils contract which provides functions to read and write JSON files containing L1 and L2 addresses. | ||
Utils utils; | ||
|
||
function setUp() public { | ||
utils = new Utils(); | ||
} | ||
|
||
/// @notice This function deploys L2VotingPowerPaused contract and writes its address to JSON file. | ||
function run() public { | ||
// Deployer's private key. This key is used to deploy the contract. | ||
uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY"); | ||
|
||
// Validate L2VotingPowerPaused contract if it is implemented correctly so that it may be used as new | ||
// implementation for the proxy contract. | ||
Options memory opts; | ||
opts.referenceContract = "L2VotingPower.sol"; | ||
opts.unsafeAllow = "constructor,external-library-linking"; | ||
Upgrades.validateUpgrade("L2VotingPowerPaused.sol", opts); | ||
|
||
console2.log("Deploying L2VotingPowerPaused contract..."); | ||
|
||
// deploy L2VotingPowerPaused contract | ||
vm.startBroadcast(deployerPrivateKey); | ||
L2VotingPowerPaused l2VotingPowerPausedImplementation = new L2VotingPowerPaused(); | ||
vm.stopBroadcast(); | ||
|
||
assert(address(l2VotingPowerPausedImplementation) != address(0)); | ||
|
||
// ERC1967Utils: keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1. | ||
assert( | ||
l2VotingPowerPausedImplementation.proxiableUUID() | ||
== bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1) | ||
); | ||
|
||
console2.log("L2VotingPowerPaused contract successfully deployed!"); | ||
console2.log("L2VotingPowerPaused (Implementation) address: %s", address(l2VotingPowerPausedImplementation)); | ||
|
||
// write L2VotingPowerPaused address to l2addresses.json | ||
Utils.L2AddressesConfig memory l2AddressesConfig = utils.readL2AddressesFile(); | ||
l2AddressesConfig.L2VotingPowerPaused = address(l2VotingPowerPausedImplementation); | ||
utils.writeL2AddressesFile(l2AddressesConfig); | ||
} | ||
} |
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