Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v3 to v4 update script #209

Merged
merged 3 commits into from
Feb 5, 2025
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 78 additions & 0 deletions lib/multiSig-tasks/update-v3-to-v4.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import chalk from "chalk";
import { task, types } from "hardhat/config";
import { HardhatRuntimeEnvironment } from "hardhat/types";
import {
getSignerAndSetDeploymentPath,
setLocalNodeDeploymentPath,
TransactionArguments,
} from "../helpers/interfaceHelper";
import {
ACCOUNT,
ACCOUNT_DESCRIPTION,
MULTISIG_UPDATE_V2_V3_DESCRIPTION,
} from "../helpers/staticVariables";
import { taskLogger } from "../logger";
import {
MULTISIG_ENCODE_PROPOSAL_PAYLOAD,
MULTISIG_SUBMIT_PROPOSAL,
MULTISIG_UPDATE_V2_V3,
soloseng marked this conversation as resolved.
Show resolved Hide resolved
} from "../tasksNames";

task(MULTISIG_UPDATE_V2_V3, MULTISIG_UPDATE_V2_V3_DESCRIPTION)
.addOptionalParam(ACCOUNT, ACCOUNT_DESCRIPTION, undefined, types.string)
.setAction(async (args: TransactionArguments, hre) => {
try {
taskLogger.setLogLevel("info");
taskLogger.info(`${MULTISIG_UPDATE_V2_V3} task...`);
await setLocalNodeDeploymentPath(hre);
const destinations: string[] = [];
const values: number[] = [];
const payloads: string[] = [];

const signer = await getSignerAndSetDeploymentPath(hre, args);

await generateContractUpdate(hre, "Manager", destinations, values, payloads);
await generateContractUpdate(hre, "SpecificGroupStrategy", destinations, values, payloads);
await generateContractUpdate(hre, "DefaultStrategy", destinations, values, payloads);
await generateContractUpdate(hre, "Account", destinations, values, payloads);
soloseng marked this conversation as resolved.
Show resolved Hide resolved

taskLogger.info("--destinations", destinations.join(","));
taskLogger.info("--values", values.join(","));
taskLogger.info("--payloads", payloads.join(","));

taskLogger.info(`Use these values with ${MULTISIG_SUBMIT_PROPOSAL} task`);

taskLogger.info(
chalk.green(
`yarn hardhat ${MULTISIG_SUBMIT_PROPOSAL} --network ${
hre.network.name
} --destinations '${destinations.join(",")}' --values '${values.join(
","
)}' --payloads '${payloads.join(",")}' --account '${await signer.getAddress()}'`
)
);
} catch (error) {
taskLogger.error("Error encoding Multisig proposal payload:", error);
}
});

async function generateContractUpdate(
hre: HardhatRuntimeEnvironment,
contractName: string,
destinations: string[],
values: number[],
payloads: string[]
) {
taskLogger.info(`Generating contract upgrade for ${contractName}`);
const accountContract = await hre.ethers.getContract(contractName);
destinations.push(accountContract.address);
values.push(0);
payloads.push(
await hre.run(MULTISIG_ENCODE_PROPOSAL_PAYLOAD, {
contract: contractName,
function: "upgradeTo",
args: (await hre.deployments.get(`${contractName}_Implementation`)).address,
})
);
}

Loading