Skip to content

Commit

Permalink
Add deployment script
Browse files Browse the repository at this point in the history
  • Loading branch information
Phanco committed Jun 11, 2024
1 parent e0df7f0 commit 5ac3c6f
Show file tree
Hide file tree
Showing 3 changed files with 113 additions and 0 deletions.
53 changes: 53 additions & 0 deletions script/contracts/L2/paused/L2GovernorPaused.s.sol
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);
}
}
56 changes: 56 additions & 0 deletions script/contracts/L2/paused/L2VotingPowerPaused.s.sol
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);
}
}
4 changes: 4 additions & 0 deletions script/contracts/Utils.sol
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ contract Utils is Script {
address L2Governor;
/// @notice The Current implementation of L2 Governor Contract.
address L2GovernorImplementation;
/// @notice The Current implementation of L2GovernorPaused Contract.
address L2GovernorPaused;
/// @notice L2 Lisk token address.
address L2LiskToken;
/// @notice L2 Locking Position contract (in Proxy), which users interact with.
Expand All @@ -51,6 +53,8 @@ contract Utils is Script {
address L2VotingPower;
/// @notice The Current implementation of L2 Voting Power Contract.
address L2VotingPowerImplementation;
/// @notice The Current implementation of L2VotingPowerPaused Contract.
address L2VotingPowerPaused;
}

/// @notice This struct is used to read MerkleRoot from JSON file.
Expand Down

0 comments on commit 5ac3c6f

Please sign in to comment.