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

refactor: Convert upgradeTo script to a hardhat task #741

Merged
merged 1 commit into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const tasks = [
"verifySpokePool",
"evmRelayMessageWithdrawal",
"testChainAdapter",
"upgradeSpokePool",
];

// eslint-disable-next-line node/no-missing-require
Expand Down
29 changes: 0 additions & 29 deletions scripts/upgradeTo.ts

This file was deleted.

29 changes: 29 additions & 0 deletions tasks/upgradeSpokePool.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { task } from "hardhat/config";
import { HardhatRuntimeEnvironment } from "hardhat/types";

task("upgrade-spokepool", "Generate calldata to upgrade a SpokePool deployment")
.addParam("implementation", "New SpokePool implementation address")
.setAction(async function (args, hre: HardhatRuntimeEnvironment) {
const { implementation } = args;
if (!implementation) {
console.log("Usage: yarn hardhat upgrade-spokepool --implementation <implementation>");
return;
}

const { deployments, ethers } = hre;

if (ethers.utils.getAddress(implementation) !== implementation) {
throw new Error(`Implementation address must be checksummed (${implementation})`);
}

// @dev Any spoke pool's interface can be used here since they all should have the same upgradeTo function signature.
const { abi } = await deployments.get("Ethereum_SpokePool");
const spokePool = new ethers.Contract(implementation, abi);

const upgradeTo = spokePool.interface.encodeFunctionData("upgradeTo", [implementation]);
console.log(`upgradeTo bytes: `, upgradeTo);

console.log(
`Call relaySpokePoolAdminFunction() with the params [<chainId>, ${upgradeTo}] on the hub pool from the owner's account.`
);
});
Loading