Skip to content

Commit

Permalink
add cm account upgrade task
Browse files Browse the repository at this point in the history
  • Loading branch information
havan committed Sep 9, 2024
1 parent 4592513 commit 769a623
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tasks/account.js
Original file line number Diff line number Diff line change
Expand Up @@ -324,4 +324,28 @@ ACCOUNT_SCOPE.task("service:list", "List supported services from CMAccount")
}
});

ACCOUNT_SCOPE.task("upgrade", "Upgrade CMAccount implementation")
.addParam("privateKey", "Private key to use")
.addParam("cmAccount", "CMAccount address")
.setAction(async (taskArgs, hre) => {
const cmAccount = await getCMAccount(taskArgs.cmAccount);
console.log("CMAccount:", taskArgs.cmAccount);

// Get new implementation
const manager = await getManager(hre);
const implementation = await manager.getAccountImplementation();
console.log("New Implementation on the Manager:", implementation);

try {
const signer = new ethers.Wallet(taskArgs.privateKey, ethers.provider);
console.log("Upgrading CMAccount implementation...");
console.log("Signer:", signer.address);
const tx = await cmAccount.connect(signer).upgradeToAndCall(implementation, "0x");
const receipt = await tx.wait();
console.log("Tx:", receipt.hash);
} catch (error) {
handleTransactionError(error, cmAccount);
}
});

module.exports = {};

0 comments on commit 769a623

Please sign in to comment.