Skip to content

Commit

Permalink
L2Claim to be upgradeable, updated test and deploy script
Browse files Browse the repository at this point in the history
  • Loading branch information
Phanco committed Dec 19, 2023
1 parent c1eec7f commit 19a4e08
Show file tree
Hide file tree
Showing 9 changed files with 982 additions and 44 deletions.
4 changes: 3 additions & 1 deletion script/L1LiskToken.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
pragma solidity 0.8.21;

import { Script, console2 } from "forge-std/Script.sol";
import { L1LiskToken, UUPSProxy } from "src/L1/L1LiskToken.sol";
import { L1LiskToken } from "src/L1/L1LiskToken.sol";
import { UUPSProxy } from "src/utils/UUPSProxy.sol";

import "script/Utils.sol";

/// @title L1LiskTokenScript - L1 Lisk token deployment script
Expand Down
38 changes: 31 additions & 7 deletions script/L2Claim.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ pragma solidity 0.8.21;

import { Script, console2 } from "forge-std/Script.sol";
import { L2Claim } from "src/L2/L2Claim.sol";
import { UUPSProxy } from "src/utils/UUPSProxy.sol";
import "script/Utils.sol";

/// @title L2ClaimScript - L2 Claim contract deployment script
Expand All @@ -25,23 +26,46 @@ contract L2ClaimScript is Script {

// get L2LiskToken contract address
Utils.L2AddressesConfig memory l2AddressesConfig = utils.readL2AddressesFile();
Utils.MerkleTree memory merkleTree = utils.readMerkleTreeFile();
console2.log("Simulation: L2 Lisk token address: %s", l2AddressesConfig.L2LiskToken);

// deploy L2Claim contract
// get MerkleTree details
Utils.MerkleTree memory merkleTree = utils.readMerkleTreeFile();
console2.log("MerkleTree Root: %s", vm.toString(merkleTree.merkleRoot));

// deploy L2Claim Implementation Contract
vm.startBroadcast(deployerPrivateKey);
L2Claim l2ClaimImplementation = new L2Claim();
vm.stopBroadcast();
assert(address(l2ClaimImplementation) != address(0));
assert(
l2ClaimImplementation.proxiableUUID() == 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc
);

// deploy L2Claim Proxy Contract
vm.startBroadcast(deployerPrivateKey);
L2Claim l2Claim = new L2Claim(address(l2AddressesConfig.L2LiskToken), merkleTree.merkleRoot);
UUPSProxy l2ClaimProxy = new UUPSProxy(address(l2ClaimImplementation), "");
vm.stopBroadcast();
assert(address(l2ClaimProxy) != address(0));

assert(address(l2Claim) != address(0));
assert(address(l2Claim.l2LiskToken()) == address(l2AddressesConfig.L2LiskToken));
// wrap in ABI to support easier calls
vm.startBroadcast(deployerPrivateKey);
L2Claim l2Claim = L2Claim(address(l2ClaimProxy));
vm.stopBroadcast();

// initialize the proxy contract (calls the initialize function in L2Claim)
vm.startBroadcast(deployerPrivateKey);
l2Claim.initialize(l2AddressesConfig.L2LiskToken, merkleTree.merkleRoot);
vm.stopBroadcast();
assert(address(l2Claim.l2LiskToken()) == l2AddressesConfig.L2LiskToken);
assert(l2Claim.merkleRoot() == merkleTree.merkleRoot);

console2.log("Simulation: L2 Claim contract successfully deployed!");
console2.log("Simulation: L2 Claim contract address: %s", address(l2Claim));
console2.log("Simulation: L2 Claim (Implementation) address: %s", address(l2ClaimImplementation));
console2.log("Simulation: L2 Claim (Proxy) address: %s", address(l2ClaimProxy));

// write L2ClaimContract address to l2addresses.json
l2AddressesConfig.L2ClaimContract = address(l2Claim);
l2AddressesConfig.L2ClaimImplementation = address(l2ClaimImplementation);
l2AddressesConfig.L2ClaimContract = address(l2ClaimProxy);
utils.writeL2AddressesFile(l2AddressesConfig);
}
}
5 changes: 4 additions & 1 deletion script/Utils.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ contract Utils is Script {

/// @notice This struct is used to read and write L2 addresses to JSON file.
struct L2AddressesConfig {
/// @notice L2 Claim contract address.
/// @notice L2 Claim contract (in Proxy), which users interact with.
address L2ClaimContract;
/// @notice The Current implementation of L2 Claim Contract.
address L2ClaimImplementation;
/// @notice L2 Lisk token address.
address L2LiskToken;
}
Expand Down Expand Up @@ -75,6 +77,7 @@ contract Utils is Script {
function writeL2AddressesFile(L2AddressesConfig memory cfg) external {
string memory json = "";
vm.serializeAddress(json, "L2ClaimContract", cfg.L2ClaimContract);
vm.serializeAddress(json, "L2ClaimImplementation", cfg.L2ClaimImplementation);
string memory finalJson = vm.serializeAddress(json, "L2LiskToken", cfg.L2LiskToken);
finalJson.write(string.concat("deployment/l2addresses.json"));
}
Expand Down
Loading

0 comments on commit 19a4e08

Please sign in to comment.