Commit before cuna
This commit is contained in:
64
scripts/initializeProxy.js
Normal file
64
scripts/initializeProxy.js
Normal file
@@ -0,0 +1,64 @@
|
||||
const { ethers } = require("hardhat");
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
|
||||
const deploymentFile = path.join(__dirname, "deployedAddresses.json");
|
||||
|
||||
async function main() {
|
||||
console.log("Initializing proxy...");
|
||||
|
||||
// Load deployment data
|
||||
const deploymentData = JSON.parse(fs.readFileSync(deploymentFile, "utf8"));
|
||||
const proxyAddress = deploymentData.proxyAddress;
|
||||
|
||||
if (!proxyAddress) {
|
||||
console.error("No proxy address found. Please deploy first.");
|
||||
return;
|
||||
}
|
||||
|
||||
console.log("Proxy address:", proxyAddress);
|
||||
|
||||
const [deployer] = await ethers.getSigners();
|
||||
console.log("Using deployer:", deployer.address);
|
||||
|
||||
// Get the contract factory
|
||||
const ContractFactory = await ethers.getContractFactory("PacaFinanceWithBoostAndScheduleUSDC", deployer);
|
||||
|
||||
// Connect to the proxy
|
||||
const contract = ContractFactory.attach(proxyAddress);
|
||||
|
||||
console.log("Calling initialize function...");
|
||||
|
||||
try {
|
||||
// Call initialize function
|
||||
const tx = await contract.initialize();
|
||||
await tx.wait();
|
||||
console.log("✅ Initialize function completed successfully");
|
||||
} catch (error) {
|
||||
console.log("❌ Initialize function failed:", error.message);
|
||||
}
|
||||
|
||||
// Test basic functions now
|
||||
try {
|
||||
const owner = await contract.owner();
|
||||
console.log("✅ Owner function works. Owner:", owner);
|
||||
} catch (error) {
|
||||
console.log("❌ Owner function failed:", error.message);
|
||||
}
|
||||
|
||||
try {
|
||||
const pool = await contract.pool();
|
||||
console.log("✅ Pool function works. Token address:", pool.tokenAddress);
|
||||
} catch (error) {
|
||||
console.log("❌ Pool function failed:", error.message);
|
||||
}
|
||||
|
||||
console.log("\nProxy initialization completed!");
|
||||
}
|
||||
|
||||
main()
|
||||
.then(() => process.exit(0))
|
||||
.catch((error) => {
|
||||
console.error(error);
|
||||
process.exit(1);
|
||||
});
|
||||
Reference in New Issue
Block a user