Skip to content

Commit

Permalink
Fixed upgradeMainnet
Browse files Browse the repository at this point in the history
  • Loading branch information
yavrsky committed Nov 20, 2024
1 parent 1570fba commit 550aa0b
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions migrations/upgradeMainnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,26 +103,31 @@ class ImaMainnetUpgrader extends Upgrader {
contractManagerInterface,
ethers.provider
)
if (!process.env.ABI) {
console.log(chalk.red("Set path to file with ABI and addresses to ABI environment variables"));
process.exit(1);
}
const abi = JSON.parse(await fs.readFile(process.env.ABI, "utf-8"));
for (const contractName of contracts) {
try {
const contractAddress = await contractManager.getContract(contractName);
console.log(`Address of ${contractName} is set to ${contractAddress}`);
} catch {
// getContract failed because the contract is not set
const contract = await this.instance.getContract(contractName);
const contractAddress = abi[`${getContractKeyInAbiFile(contractName)}_address`] as string;
this.transactions.push(Transaction.from(
{
to: await contractManager.getAddress(),
data: contractManager.interface.encodeFunctionData(
"setContractsAddress",
[
contractName,
await contract.getAddress()
contractAddress
]
)
}
))
console.log(`Set ${contractName} address to ${await contract.getAddress()}`);
console.log(`Set ${contractName} address to ${contractAddress}`);
}
}
};
Expand Down Expand Up @@ -154,10 +159,14 @@ async function updateAbi() {
}

async function main() {
const contractNamesToUpgrade = [
"MessageProxyForMainnet",
"CommunityPool"
]
let contractNamesToUpgrade = contracts;
if (process.env.TEST_UPGRADE !== "true") {
contractNamesToUpgrade = [
"MessageProxyForMainnet",
"CommunityPool"
]

}
const upgrader = new ImaMainnetUpgrader(
"2.1.0",
await getImaMainnetInstance(),
Expand Down

0 comments on commit 550aa0b

Please sign in to comment.