diff --git a/foundry.toml b/foundry.toml index 7ae1284..290ff09 100644 --- a/foundry.toml +++ b/foundry.toml @@ -16,13 +16,25 @@ ffi = true ast = true build_info = true extra_output = ["storageLayout"] + +# RPC Configuration +[rpc_endpoints] +pushchain = "https://evm.rpc-testnet-donut-node1.push.org/" +pushlocalnet = "http://127.0.0.1:8545" +sepolia = "https://sepolia.infura.io/v3/${INFURA_PROJECT_ID}" +mainnet = "https://mainnet.infura.io/v3/${INFURA_PROJECT_ID}" + +# Private Keys +[profile.env] +PRIVATE = "${PRIVATE_KEY}" + # See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options [fmt] - bracket_spacing = true - int_types = "long" - line_length = 120 - multiline_func_header = "all" - number_underscore = "thousands" - quote_style = "double" - tab_width = 4 - wrap_comments = true +bracket_spacing = true +int_types = "long" +line_length = 120 +multiline_func_header = "all" +number_underscore = "thousands" +quote_style = "double" +tab_width = 4 +wrap_comments = true diff --git a/hardhat.config.js b/hardhat.config.js index ef245e9..35dcebe 100644 --- a/hardhat.config.js +++ b/hardhat.config.js @@ -33,7 +33,7 @@ module.exports = { }, pushchain: { - url: "https://evm.pn1.dev.push.org", + url: "https://evm.rpc-testnet-donut-node1.push.org/", accounts: [process.env.PRIVATE] , }, @@ -47,6 +47,10 @@ module.exports = { url: `https://sepolia.infura.io/v3/${process.env.INFURA_PROJECT_ID}`, accounts: [process.env.PRIVATE] + }, + mainnet: { + url: `https://mainnet.infura.io/v3/${process.env.INFURA_PROJECT_ID}`, + accounts: [process.env.PRIVATE] } }, }; diff --git a/script/legacyDeployment/DeployRelease.js b/script/deploy/HardhatDeployRelease.js similarity index 99% rename from script/legacyDeployment/DeployRelease.js rename to script/deploy/HardhatDeployRelease.js index 740cc01..4a19335 100644 --- a/script/legacyDeployment/DeployRelease.js +++ b/script/deploy/HardhatDeployRelease.js @@ -27,4 +27,4 @@ async function main() { main().catch((err) => { console.error("Error in deploy script:", err); process.exit(1); -}); +}); \ No newline at end of file diff --git a/script/legacyDeployment/DeployLocker.js b/script/legacyDeployment/DeployLocker.js deleted file mode 100644 index 55f1ec2..0000000 --- a/script/legacyDeployment/DeployLocker.js +++ /dev/null @@ -1,25 +0,0 @@ -const fs = require("fs"); -const path = require("path"); -const { ethers, upgrades, network } = require("hardhat"); - -async function main() { - const [deployer] = await ethers.getSigners(); - - console.log("Deployer:", deployer.address); - const MigrationLocker = await ethers.getContractFactory("MigrationLocker"); - - console.log("Deploying MigrationLocker with transparent proxy..."); - const locker = await upgrades.deployProxy( - MigrationLocker, - [deployer.address], - { kind: "transparent", initializer: "initialize" } - ); - await locker.waitForDeployment(); - console.log("MigrationLocker proxy deployed to:", locker.target); - -} - -main().catch((err) => { - console.error("Error in deploy script:", err); - process.exit(1); -}); diff --git a/script/testUtils/getPoof.js b/script/testUtils/getPoof.js index 543b77e..a33c002 100644 --- a/script/testUtils/getPoof.js +++ b/script/testUtils/getPoof.js @@ -1,7 +1,7 @@ -const whitelist = require("../../output/claims.json"); +const whitelist = require("../../output/migration-list.json"); const { getProof } = require("../utils/merkle"); const user = whitelist[0]; -const proof = getProof(user.address, user.amount, whitelist); +const proof = getProof(user.address, user.amount, user.epoch, whitelist); console.log("Merkle Proof for user:", user.address); console.log(proof); diff --git a/script/testUtils/proofArray.js b/script/testUtils/proofArray.js index 5f8c26b..e98a446 100644 --- a/script/testUtils/proofArray.js +++ b/script/testUtils/proofArray.js @@ -1,9 +1,9 @@ -const whitelist = require("../../output/claims.json"); +const whitelist = require("../../output/migration-list.json"); const { getProof, verify } = require("../utils/merkle"); for (const user of whitelist) { - const proof = getProof(user.address, user.amount, whitelist); - const valid = verify(user.address, user.amount, whitelist); + const proof = getProof(user.address, user.amount, user.epoch, whitelist); + const valid = verify(user.address, user.amount, user.epoch, whitelist); console.log("User:", user.address); console.log("Proof:", proof); diff --git a/script/testUtils/verify.js b/script/testUtils/verify.js index d2f2dd0..8a6dcd0 100644 --- a/script/testUtils/verify.js +++ b/script/testUtils/verify.js @@ -1,6 +1,6 @@ -const whitelist = require("../../output/claims.json"); +const whitelist = require("../../output/migration-list.json"); const { verify } = require("../utils/merkle"); const user = whitelist[0]; -const isValid = verify(user.address, user.amount, whitelist); +const isValid = verify(user.address, user.amount, user.epoch, whitelist); console.log("Proof valid?", isValid); diff --git a/script/upgrade/UpgradeLocker.s.sol b/script/upgrade/UpgradeLocker.s.sol new file mode 100644 index 0000000..b9ab3d5 --- /dev/null +++ b/script/upgrade/UpgradeLocker.s.sol @@ -0,0 +1,50 @@ +// SPDX-License-Identifier: SEE LICENSE IN LICENSE +pragma solidity 0.8.29; + +import "forge-std/Script.sol"; +import "../../src/MigrationLocker.sol"; +import { ITransparentUpgradeableProxy } from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; +import "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol"; + +/** + * @title UpgradeLocker + * @dev Upgrade script for MigrationLocker contract + * This script handles: + * 1. Deployment of the new implementation contract + * 2. Upgrading the proxy to point to the new implementation + */ +contract UpgradeLockerScript is Script { + // Storage slot for ProxyAdmin in TransparentUpgradeableProxy + bytes32 constant PROXY_ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103; + + function run() external { + // Get private key from environment + uint256 deployerPrivateKey = vm.envUint("DEPLOYER_OWNER"); + address deployerAddress = vm.addr(deployerPrivateKey); + + // Get proxy address from environment + address proxyAddress = 0xEf9898A2476bd7b3801e9D257d4c39279eF1583c; + + vm.startBroadcast(deployerPrivateKey); + + console.log("Upgrading contracts with address:", deployerAddress); + console.log("Current proxy address:", proxyAddress); + + // Deploy new implementation + MigrationLocker newImplementation = new MigrationLocker(); + console.log("New MigrationLocker implementation deployed at:", address(newImplementation)); + + // Get the proxy admin contract from storage slot + address proxyAdminAddress = address(uint160(uint256(vm.load(proxyAddress, PROXY_ADMIN_SLOT)))); + ProxyAdmin proxyAdmin = ProxyAdmin(proxyAdminAddress); + console.log("ProxyAdmin address:", proxyAdminAddress); + + // Upgrade the proxy to point to the new implementation + proxyAdmin.upgradeAndCall( + ITransparentUpgradeableProxy(payable(proxyAddress)), address(newImplementation), bytes("") + ); + console.log("Proxy upgraded to new implementation"); + + vm.stopBroadcast(); + } +} diff --git a/script/upgrade/UpgradeRelease.s.sol b/script/upgrade/UpgradeRelease.s.sol new file mode 100644 index 0000000..a510efd --- /dev/null +++ b/script/upgrade/UpgradeRelease.s.sol @@ -0,0 +1,50 @@ +// SPDX-License-Identifier: SEE LICENSE IN LICENSE +pragma solidity 0.8.29; + +import "forge-std/Script.sol"; +import "../../src/MigrationRelease.sol"; +import { ITransparentUpgradeableProxy } from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; +import "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol"; + +/** + * @title UpgradeRelease + * @dev Upgrade script for MigrationRelease contract + * This script handles: + * 1. Deployment of the new implementation contract + * 2. Upgrading the proxy to point to the new implementation + */ +contract UpgradeReleaseScript is Script { + // Storage slot for ProxyAdmin in TransparentUpgradeableProxy + bytes32 constant PROXY_ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103; + + function run() external { + // Get private key from environment + uint256 deployerPrivateKey = vm.envUint("DEPLOYER_OWNER"); + address deployerAddress = vm.addr(deployerPrivateKey); + + // Get proxy address from environment + address proxyAddress = 0x95CFE535e2Eea0EB1620fa1d10549b67e284Ba52; + + vm.startBroadcast(deployerPrivateKey); + + console.log("Upgrading contracts with address:", deployerAddress); + console.log("Current proxy address:", proxyAddress); + + // Deploy new implementation + MigrationRelease newImplementation = new MigrationRelease(); + console.log("New MigrationRelease implementation deployed at:", address(newImplementation)); + + // Get the proxy admin contract from storage slot + address proxyAdminAddress = address(uint160(uint256(vm.load(proxyAddress, PROXY_ADMIN_SLOT)))); + ProxyAdmin proxyAdmin = ProxyAdmin(proxyAdminAddress); + console.log("ProxyAdmin address:", proxyAdminAddress); + + // Upgrade the proxy to point to the new implementation + proxyAdmin.upgradeAndCall( + ITransparentUpgradeableProxy(payable(proxyAddress)), address(newImplementation), bytes("") + ); + console.log("Proxy upgraded to new implementation"); + + vm.stopBroadcast(); + } +}