Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace L2VestingWalletPaused by L2VestingWalletEmergencyWithdraw #197

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
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
62 changes: 62 additions & 0 deletions script/contracts/L1/paused/L1VestingWalletEmergencyWithdraw.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// 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 { L1VestingWalletEmergencyWithdraw } from "src/L1/paused/L1VestingWalletEmergencyWithdraw.sol";
import "script/contracts/Utils.sol";

/// @title L1VestingWalletEmergencyWithdrawScript - L1VestingWalletEmergencyWithdraw contract deployment script
/// @notice This contract is used to deploy L1VestingWalletEmergencyWithdraw contract and write its address to JSON
/// file.
contract L1VestingWalletEmergencyWithdrawScript 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 L1VestingWalletEmergencyWithdraw 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 L1VestingWalletEmergencyWithdraw contract if it is implemented correctly so that it may be used as
// new
// implementation for the proxy contract.
Options memory opts;
opts.referenceContract = "L1VestingWallet.sol";
opts.unsafeAllow = "constructor";
Upgrades.validateUpgrade("L1VestingWalletEmergencyWithdraw.sol", opts);

console2.log("Deploying L1VestingWalletEmergencyWithdraw contract...");

// deploy L1VestingWalletEmergencyWithdraw contract
vm.startBroadcast(deployerPrivateKey);
L1VestingWalletEmergencyWithdraw l1VestingWalletEmergencyWithdrawImplementation =
new L1VestingWalletEmergencyWithdraw();
vm.stopBroadcast();

assert(address(l1VestingWalletEmergencyWithdrawImplementation) != address(0));

// ERC1967Utils: keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1.
assert(
l1VestingWalletEmergencyWithdrawImplementation.proxiableUUID()
== bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1)
);

console2.log("L1VestingWalletEmergencyWithdraw contract successfully deployed!");
console2.log(
"L1VestingWalletEmergencyWithdraw (Implementation) address: %s",
address(l1VestingWalletEmergencyWithdrawImplementation)
);

// write L1VestingWalletEmergencyWithdraw address to l1addresses.json
Utils.L1AddressesConfig memory l1AddressesConfig = utils.readL1AddressesFile(utils.getL1AddressesFilePath());
l1AddressesConfig.L1VestingWalletEmergencyWithdraw = address(l1VestingWalletEmergencyWithdrawImplementation);
utils.writeL1AddressesFile(l1AddressesConfig, utils.getL1AddressesFilePath());
}
}
56 changes: 0 additions & 56 deletions script/contracts/L1/paused/L1VestingWalletPaused.s.sol

This file was deleted.

62 changes: 62 additions & 0 deletions script/contracts/L2/paused/L2VestingWalletEmergencyWithdraw.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// 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 { L2VestingWalletEmergencyWithdraw } from "src/L2/paused/L2VestingWalletEmergencyWithdraw.sol";
import "script/contracts/Utils.sol";

/// @title L2VestingWalletEmergencyWithdrawScript - L2VestingWalletEmergencyWithdraw contract deployment script
/// @notice This contract is used to deploy L2VestingWalletEmergencyWithdraw contract and write its address to JSON
/// file.
contract L2VestingWalletEmergencyWithdrawScript 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 L2VestingWalletEmergencyWithdraw 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 L2VestingWalletEmergencyWithdraw contract if it is implemented correctly so that it may be used as
// new
// implementation for the proxy contract.
Options memory opts;
opts.referenceContract = "L2VestingWallet.sol";
opts.unsafeAllow = "constructor";
Upgrades.validateUpgrade("L2VestingWalletEmergencyWithdraw.sol", opts);

console2.log("Deploying L2VestingWalletEmergencyWithdraw contract...");

// deploy L2VestingWalletEmergencyWithdraw contract
vm.startBroadcast(deployerPrivateKey);
L2VestingWalletEmergencyWithdraw l2VestingWalletEmergencyWithdrawImplementation =
new L2VestingWalletEmergencyWithdraw();
vm.stopBroadcast();

assert(address(l2VestingWalletEmergencyWithdrawImplementation) != address(0));

// ERC1967Utils: keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1.
assert(
l2VestingWalletEmergencyWithdrawImplementation.proxiableUUID()
== bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1)
);

console2.log("L2VestingWalletEmergencyWithdraw contract successfully deployed!");
console2.log(
"L2VestingWalletEmergencyWithdraw (Implementation) address: %s",
address(l2VestingWalletEmergencyWithdrawImplementation)
);

// write L2VestingWalletEmergencyWithdraw address to l2addresses.json
Utils.L2AddressesConfig memory l2AddressesConfig = utils.readL2AddressesFile(utils.getL2AddressesFilePath());
l2AddressesConfig.L2VestingWalletEmergencyWithdraw = address(l2VestingWalletEmergencyWithdrawImplementation);
utils.writeL2AddressesFile(l2AddressesConfig, utils.getL2AddressesFilePath());
}
}
56 changes: 0 additions & 56 deletions script/contracts/L2/paused/L2VestingWalletPaused.s.sol

This file was deleted.

25 changes: 15 additions & 10 deletions script/contracts/Utils.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ contract Utils is Script {
address L1LiskToken;
/// @notice The Current implementation of L1 Vesting Wallet.
address L1VestingWalletImplementation;
/// @notice L1 VestingWalletPaused address.
address L1VestingWalletPaused;
/// @notice L1 VestingWalletEmergencyWithdraw address.
address L1VestingWalletEmergencyWithdraw;
}

/// @notice This struct is used to read and write L2 addresses to JSON file.
Expand Down Expand Up @@ -57,8 +57,8 @@ contract Utils is Script {
address L2TimelockController;
/// @notice The Current implementation of L2 Vesting Wallet.
address L2VestingWalletImplementation;
/// @notice L2 VestingWalletPaused address.
address L2VestingWalletPaused;
/// @notice L2 VestingWalletEmergencyWithdraw address.
address L2VestingWalletEmergencyWithdraw;
/// @notice L2 Voting Power contract (in Proxy), which users interact with.
address L2VotingPower;
/// @notice The Current implementation of L2 Voting Power Contract.
Expand Down Expand Up @@ -156,8 +156,10 @@ contract Utils is Script {
l1AddressesConfig.L1VestingWalletImplementation = l1VestingWalletImplementation;
} catch { }

try vm.parseJsonAddress(addressJson, ".L1VestingWalletPaused") returns (address l1VestingWalletPaused) {
l1AddressesConfig.L1VestingWalletPaused = l1VestingWalletPaused;
try vm.parseJsonAddress(addressJson, ".L1VestingWalletEmergencyWithdraw") returns (
address l1VestingWalletEmergencyWithdraw
) {
l1AddressesConfig.L1VestingWalletEmergencyWithdraw = l1VestingWalletEmergencyWithdraw;
} catch { }

return l1AddressesConfig;
Expand All @@ -170,7 +172,8 @@ contract Utils is Script {
string memory json = "";
vm.serializeAddress(json, "L1LiskToken", cfg.L1LiskToken);
vm.serializeAddress(json, "L1VestingWalletImplementation", cfg.L1VestingWalletImplementation);
string memory finalJson = vm.serializeAddress(json, "L1VestingWalletPaused", cfg.L1VestingWalletPaused);
string memory finalJson =
vm.serializeAddress(json, "L1VestingWalletEmergencyWithdraw", cfg.L1VestingWalletEmergencyWithdraw);
finalJson.write(filePath);
}

Expand Down Expand Up @@ -258,8 +261,10 @@ contract Utils is Script {
l2AddressesConfig.L2VestingWalletImplementation = l2VestingWalletImplementation;
} catch { }

try vm.parseJsonAddress(addressJson, ".L2VestingWalletPaused") returns (address l2VestingWalletPaused) {
l2AddressesConfig.L2VestingWalletPaused = l2VestingWalletPaused;
try vm.parseJsonAddress(addressJson, ".L2VestingWalletEmergencyWithdraw") returns (
address l2VestingWalletEmergencyWithdraw
) {
l2AddressesConfig.L2VestingWalletEmergencyWithdraw = l2VestingWalletEmergencyWithdraw;
} catch { }

try vm.parseJsonAddress(addressJson, ".L2VotingPower") returns (address l2VotingPower) {
Expand Down Expand Up @@ -301,7 +306,7 @@ contract Utils is Script {
vm.serializeAddress(json, "L2StakingImplementation", cfg.L2StakingImplementation);
vm.serializeAddress(json, "L2TimelockController", cfg.L2TimelockController);
vm.serializeAddress(json, "L2VestingWalletImplementation", cfg.L2VestingWalletImplementation);
vm.serializeAddress(json, "L2VestingWalletPaused", cfg.L2VestingWalletPaused);
vm.serializeAddress(json, "L2VestingWalletEmergencyWithdraw", cfg.L2VestingWalletEmergencyWithdraw);
vm.serializeAddress(json, "L2VotingPower", cfg.L2VotingPower);
vm.serializeAddress(json, "L2VotingPowerImplementation", cfg.L2VotingPowerImplementation);
string memory finalJson = vm.serializeAddress(json, "L2VotingPowerPaused", cfg.L2VotingPowerPaused);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,18 @@ echo "Cleaning up the build artifacts to be able to deploy the contract..."
forge clean
echo "Done."

echo "Deploying and if enabled verifying L2VestingWalletPaused smart contract..."
echo "Deploying and if enabled verifying L2VestingWalletEmergencyWithdraw smart contract..."
if [ -z "$CONTRACT_VERIFIER" ]
then
forge script --rpc-url="$L2_RPC_URL" --broadcast -vvvv script/contracts/L2/paused/L2VestingWalletPaused.s.sol:L2VestingWalletPausedScript
forge script --rpc-url="$L2_RPC_URL" --broadcast -vvvv script/contracts/L2/paused/L2VestingWalletEmergencyWithdraw.s.sol:L2VestingWalletEmergencyWithdrawScript
else
if [ $CONTRACT_VERIFIER = "blockscout" ]
then
forge script --rpc-url="$L2_RPC_URL" --broadcast --verify --verifier blockscout --verifier-url $L2_VERIFIER_URL -vvvv script/contracts/L2/paused/L2VestingWalletPaused.s.sol:L2VestingWalletPausedScript
forge script --rpc-url="$L2_RPC_URL" --broadcast --verify --verifier blockscout --verifier-url $L2_VERIFIER_URL -vvvv script/contracts/L2/paused/L2VestingWalletEmergencyWithdraw.s.sol:L2VestingWalletEmergencyWithdrawScript
fi
if [ $CONTRACT_VERIFIER = "etherscan" ]
then
forge script --rpc-url="$L2_RPC_URL" --broadcast --verify --verifier etherscan --etherscan-api-key="$L2_ETHERSCAN_API_KEY" -vvvv script/contracts/L2/paused/L2VestingWalletPaused.s.sol:L2VestingWalletPausedScript
forge script --rpc-url="$L2_RPC_URL" --broadcast --verify --verifier etherscan --etherscan-api-key="$L2_ETHERSCAN_API_KEY" -vvvv script/contracts/L2/paused/L2VestingWalletEmergencyWithdraw.s.sol:L2VestingWalletEmergencyWithdrawScript
fi
fi
echo "Done."
Expand All @@ -51,18 +51,18 @@ echo "Cleaning up the build artifacts to be able to deploy the next contract..."
forge clean
echo "Done."

echo "Deploying and if enabled verifying L1VestingWalletPaused smart contract..."
echo "Deploying and if enabled verifying L1VestingWalletEmergencyWithdraw smart contract..."
if [ -z "$CONTRACT_VERIFIER" ]
then
forge script --rpc-url="$L1_RPC_URL" --broadcast -vvvv script/contracts/L1/paused/L1VestingWalletPaused.s.sol:L1VestingWalletPausedScript
forge script --rpc-url="$L1_RPC_URL" --broadcast -vvvv script/contracts/L1/paused/L1VestingWalletEmergencyWithdraw.s.sol:L1VestingWalletEmergencyWithdrawScript
else
if [ $CONTRACT_VERIFIER = "blockscout" ]
then
forge script --rpc-url="$L1_RPC_URL" --broadcast --verify --verifier blockscout --verifier-url $L1_VERIFIER_URL -vvvv script/contracts/L1/paused/L1VestingWalletPaused.s.sol:L1VestingWalletPausedScript
forge script --rpc-url="$L1_RPC_URL" --broadcast --verify --verifier blockscout --verifier-url $L1_VERIFIER_URL -vvvv script/contracts/L1/paused/L1VestingWalletEmergencyWithdraw.s.sol:L1VestingWalletEmergencyWithdrawScript
fi
if [ $CONTRACT_VERIFIER = "etherscan" ]
then
forge script --rpc-url="$L1_RPC_URL" --broadcast --verify --verifier etherscan --etherscan-api-key="$L1_ETHERSCAN_API_KEY" -vvvv script/contracts/L1/paused/L1VestingWalletPaused.s.sol:L1VestingWalletPausedScript
forge script --rpc-url="$L1_RPC_URL" --broadcast --verify --verifier etherscan --etherscan-api-key="$L1_ETHERSCAN_API_KEY" -vvvv script/contracts/L1/paused/L1VestingWalletEmergencyWithdraw.s.sol:L1VestingWalletEmergencyWithdrawScript
fi
fi
echo "Done."
11 changes: 11 additions & 0 deletions src/L1/paused/L1VestingWalletEmergencyWithdraw.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity 0.8.23;

import { L2VestingWalletEmergencyWithdraw } from "src/L2/paused/L2VestingWalletEmergencyWithdraw.sol";

/// @title L1VestingWalletEmergencyWithdraw - Paused version of L1VestingWallet contract
/// @notice This contract is used to pause the L1VestingWallet contract. In case of any emergency, the owner can upgrade
/// and
/// pause the contract to prevent any further vesting operations.
/// L1VestingWalletEmergencyWithdraw shares the same functionality of L2VestingWalletEmergencyWithdraw.
contract L1VestingWalletEmergencyWithdraw is L2VestingWalletEmergencyWithdraw { }
Loading
Loading