Files
pacahh/scripts/importBaseProxy.js
2025-09-04 02:48:34 +02:00

44 lines
1.5 KiB
JavaScript

const { ethers, upgrades } = require("hardhat");
const path = require("path");
require('dotenv').config({ path: path.join(__dirname, '..', '.env') });
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}`);
}
// Get Base proxy address from env
const proxyAddress = process.env.PROXY_ADDRESS_BASE;
if (!proxyAddress) {
console.error("PROXY_ADDRESS_BASE not found in .env file");
process.exit(1);
}
console.log(`Importing Base proxy at: ${proxyAddress}`);
// Get the current implementation contract factory
const Paca = await ethers.getContractFactory("PacaFinanceWithBoostAndScheduleBase", deployer);
// Force import the proxy to fix artifacts
console.log("Force importing proxy...");
await upgrades.forceImport(proxyAddress, Paca);
console.log("✅ Base proxy imported successfully!");
console.log("You can now delete this script and run normal upgrades.");
}
main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});