From 9cbfa0857cfbf6ae5a6a29652fdf3929f911de98 Mon Sep 17 00:00:00 2001 From: yuetloo Date: Fri, 1 Dec 2023 11:31:33 -0500 Subject: [PATCH] move cancel script from tasks to cli --- contracts/cli/cancelRound.ts | 36 ++++++++++++++++++++++++++++++++++ contracts/tasks/cancelRound.ts | 17 ---------------- 2 files changed, 36 insertions(+), 17 deletions(-) create mode 100644 contracts/cli/cancelRound.ts delete mode 100644 contracts/tasks/cancelRound.ts diff --git a/contracts/cli/cancelRound.ts b/contracts/cli/cancelRound.ts new file mode 100644 index 000000000..27e597501 --- /dev/null +++ b/contracts/cli/cancelRound.ts @@ -0,0 +1,36 @@ +/** + * Cancel the current round + * + * Sample usage: + * HARDHAT_NETWORK=localhost yarn ts-node cli/cancelRound.ts + */ +import { ethers, network } from 'hardhat' +import { program } from 'commander' + +program + .description('Cancel the current round') + .argument('clrfund', 'The ClrFund contract address') + .parse() + +async function main(args: any) { + const [deployer] = await ethers.getSigners() + console.log('deployer', deployer.address) + console.log('network', network.name) + + const clrfundContract = await ethers.getContractAt( + 'ClrFund', + args[0], + deployer + ) + + const cancelTx = await clrfundContract.cancelCurrentRound() + await cancelTx.wait() + console.log('Cancel transaction hash: ', cancelTx.hash) +} + +main(program.args) + .then(() => process.exit(0)) + .catch((error) => { + console.error(error) + process.exit(1) + }) diff --git a/contracts/tasks/cancelRound.ts b/contracts/tasks/cancelRound.ts deleted file mode 100644 index f1cb010d5..000000000 --- a/contracts/tasks/cancelRound.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { task } from 'hardhat/config' - -task('cancel-round', 'Cancel the current round') - .addParam('clrfund', 'The ClrFund contract address') - .setAction(async ({ clrfund }, { ethers }) => { - const [deployer] = await ethers.getSigners() - console.log('deployer', deployer.address) - const clrfundContract = await ethers.getContractAt( - 'ClrFund', - clrfund, - deployer - ) - - const cancelTx = await clrfundContract.cancelCurrentRound() - await cancelTx.wait() - console.log('Cancel transaction hash: ', cancelTx.hash) - })