Currently deployed, has vesting tracker
This commit is contained in:
@@ -1,17 +1,24 @@
|
||||
const { ethers, upgrades, run } = require("hardhat");
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
require('dotenv').config();
|
||||
require('dotenv').config({ path: path.join(__dirname, '..', '.env') });
|
||||
|
||||
const deploymentFile = path.join(__dirname, "deployedAddresses.json");
|
||||
|
||||
async function main() {
|
||||
const privateKey = process.env.pk;
|
||||
const privateKey = process.env.PRIVATE_KEY;
|
||||
const network = await hre.network.name;
|
||||
|
||||
const wallet = new ethers.Wallet(privateKey, ethers.provider);
|
||||
const deployer = wallet.connect(ethers.provider);
|
||||
console.log(`Using private key for account: ${deployer.address}`);
|
||||
let deployer;
|
||||
if (network === "hardhat" || network === "localhost") {
|
||||
// Use default hardhat account for local testing
|
||||
[deployer] = await ethers.getSigners();
|
||||
console.log(`Using default hardhat account: ${deployer.address}`);
|
||||
} else {
|
||||
const wallet = new ethers.Wallet(privateKey, ethers.provider);
|
||||
deployer = wallet.connect(ethers.provider);
|
||||
console.log(`Using private key for account: ${deployer.address}`);
|
||||
}
|
||||
console.log("Deploying contracts with the account:", deployer.address);
|
||||
|
||||
let deploymentData = {};
|
||||
@@ -19,12 +26,25 @@ async function main() {
|
||||
deploymentData = JSON.parse(fs.readFileSync(deploymentFile, "utf8"));
|
||||
}
|
||||
|
||||
const contractName = network === "mainnet"
|
||||
? "PacaFinanceWithBoostAndScheduleUSDT"
|
||||
: "PacaFinanceWithBoostAndScheduleUSDC";
|
||||
|
||||
// Select contract and proxy address based on network
|
||||
let contractName;
|
||||
let proxyAddress;
|
||||
if (!deploymentData.proxyAddress) {
|
||||
if (network === "base") {
|
||||
contractName = "PacaFinanceWithBoostAndScheduleBase";
|
||||
proxyAddress = process.env.PROXY_ADDRESS_BASE;
|
||||
} else if (network === "sonic") {
|
||||
contractName = "PacaFinanceWithBoostAndScheduleSonic";
|
||||
proxyAddress = process.env.PROXY_ADDRESS_SONIC || deploymentData.proxyAddress;
|
||||
} else if (network === "mainnet") {
|
||||
contractName = "PacaFinanceWithBoostAndScheduleBsc";
|
||||
proxyAddress = process.env.PROXY_ADDRESS_BSC || deploymentData.proxyAddress;
|
||||
} else {
|
||||
// Default to BSC for other networks (like test networks)
|
||||
contractName = "PacaFinanceWithBoostAndScheduleBsc";
|
||||
proxyAddress = deploymentData.proxyAddress;
|
||||
}
|
||||
|
||||
if (!proxyAddress) {
|
||||
// Initial deployment
|
||||
console.log("Deploying proxy...");
|
||||
const Paca = await ethers.getContractFactory(contractName, deployer);
|
||||
@@ -46,12 +66,9 @@ async function main() {
|
||||
await verifyContract(implementationAddress, contractName);
|
||||
} else {
|
||||
// Upgrade
|
||||
proxyAddress = deploymentData.proxyAddress;
|
||||
console.log("Upgrading proxy...");
|
||||
|
||||
const Paca = await ethers.getContractFactory(contractName, deployer);
|
||||
// //commen tout for mainet
|
||||
// await upgrades.forceImport(proxyAddress, Paca);
|
||||
|
||||
// Get current implementation for comparison
|
||||
const oldImplementationAddress = await upgrades.erc1967.getImplementationAddress(proxyAddress);
|
||||
|
||||
112
scripts/manualUpgrade.js
Normal file
112
scripts/manualUpgrade.js
Normal file
@@ -0,0 +1,112 @@
|
||||
const { ethers } = require("hardhat");
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
require('dotenv').config({ path: path.join(__dirname, '..', '.env') });
|
||||
|
||||
const deploymentFile = path.join(__dirname, "deployedAddresses.json");
|
||||
|
||||
async function main() {
|
||||
const privateKey = process.env.PRIVATE_KEY;
|
||||
const network = await hre.network.name;
|
||||
|
||||
let deployer;
|
||||
if (network === "hardhat" || network === "localhost") {
|
||||
[deployer] = await ethers.getSigners();
|
||||
console.log(`Using default hardhat account: ${deployer.address}`);
|
||||
} else {
|
||||
const wallet = new ethers.Wallet(privateKey, ethers.provider);
|
||||
deployer = wallet.connect(ethers.provider);
|
||||
console.log(`Using private key for account: ${deployer.address}`);
|
||||
}
|
||||
console.log("Deploying contracts with the account:", deployer.address);
|
||||
|
||||
// Select contract based on network
|
||||
let contractName;
|
||||
if (network === "base") {
|
||||
contractName = "PacaFinanceWithBoostAndScheduleBase";
|
||||
} else if (network === "sonic") {
|
||||
contractName = "PacaFinanceWithBoostAndScheduleSonic";
|
||||
} else if (network === "mainnet") {
|
||||
contractName = "PacaFinanceWithBoostAndScheduleBsc";
|
||||
} else {
|
||||
contractName = "PacaFinanceWithBoostAndScheduleBsc";
|
||||
}
|
||||
|
||||
console.log(`Deploying ${contractName} for network: ${network}`);
|
||||
|
||||
// Read deployment data
|
||||
let deploymentData = {};
|
||||
if (fs.existsSync(deploymentFile)) {
|
||||
deploymentData = JSON.parse(fs.readFileSync(deploymentFile, "utf8"));
|
||||
}
|
||||
|
||||
if (!deploymentData.proxyAddress) {
|
||||
console.error("No proxy address found in deployment file!");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const proxyAddress = deploymentData.proxyAddress;
|
||||
console.log("Proxy address:", proxyAddress);
|
||||
|
||||
// Deploy new implementation contract
|
||||
console.log("Deploying new implementation contract...");
|
||||
const PacaFactory = await ethers.getContractFactory(contractName, deployer);
|
||||
const newImplementation = await PacaFactory.deploy();
|
||||
await newImplementation.waitForDeployment();
|
||||
|
||||
const newImplementationAddress = await newImplementation.getAddress();
|
||||
console.log("New implementation deployed to:", newImplementationAddress);
|
||||
|
||||
// ProxyAdmin contract address
|
||||
const proxyAdminAddress = "0x3459Fe72D4274d40d449aE1806F8E2149302F28B";
|
||||
|
||||
// ProxyAdmin ABI with upgradeAndCall function
|
||||
const proxyAdminABI = [
|
||||
"function upgradeAndCall(address proxy, address implementation, bytes data) external payable"
|
||||
];
|
||||
|
||||
// Connect to ProxyAdmin contract
|
||||
const proxyAdmin = new ethers.Contract(proxyAdminAddress, proxyAdminABI, deployer);
|
||||
|
||||
// Perform upgrade with empty call data
|
||||
console.log("Performing upgrade via ProxyAdmin...");
|
||||
console.log("ProxyAdmin address:", proxyAdminAddress);
|
||||
const upgradeTx = await proxyAdmin.upgradeAndCall(proxyAddress, newImplementationAddress, "0x");
|
||||
console.log("Upgrade transaction hash:", upgradeTx.hash);
|
||||
|
||||
// Wait for transaction confirmation
|
||||
await upgradeTx.wait();
|
||||
console.log("Upgrade completed successfully!");
|
||||
|
||||
// Update deployment data
|
||||
deploymentData.implementationAddress = newImplementationAddress;
|
||||
fs.writeFileSync(deploymentFile, JSON.stringify(deploymentData, null, 2));
|
||||
console.log("Deployment data updated");
|
||||
|
||||
// Verify the new implementation
|
||||
console.log("Waiting 10 seconds before verification...");
|
||||
await new Promise(resolve => setTimeout(resolve, 10000));
|
||||
|
||||
try {
|
||||
await hre.run("verify:verify", {
|
||||
address: newImplementationAddress,
|
||||
constructorArguments: []
|
||||
});
|
||||
console.log("Contract verified successfully.");
|
||||
} catch (err) {
|
||||
if (err.message.includes("already been verified")) {
|
||||
console.log("Contract is already verified.");
|
||||
} else {
|
||||
console.log("Verification failed:", err.message);
|
||||
console.log(`\nTo verify manually, run:`);
|
||||
console.log(`npx hardhat verify --network ${network} ${newImplementationAddress}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
main()
|
||||
.then(() => process.exit(0))
|
||||
.catch((error) => {
|
||||
console.error(error);
|
||||
process.exit(1);
|
||||
});
|
||||
Reference in New Issue
Block a user