Skip to content

Commit

Permalink
[FEATURE/CROW-296] Add cancel task
Browse files Browse the repository at this point in the history
  • Loading branch information
emilianaARomero committed Jun 28, 2023
1 parent 50c39a1 commit 7ae334d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,11 @@ Boilerplate comes with some example tasks:

- Transfer tokens: `npx hardhat transfer --tokenaddress 0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512 --account 0x70997970C51812dc3A010C7d01b50e0d17dc79C8 --amount 0.1 --network localhost`

- Pledge a campaing: `npx hardhat pledge --goal 1 --campaign-id 5 --address 0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512 --network localhost`
- Pledge a campaign: `npx hardhat pledge --goal 1 --campaign-id 5 --address 0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512 --network localhost`

- Refund a campaing: `npx hardhat refund --campaign-id 1 --address 0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512 --network localhost`
- Refund a campaign: `npx hardhat refund --campaign-id 1 --address 0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512 --network localhost`

- Cancel a campaign: `npx hardhat cancel --address 0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512 --campaign-id 1`

- Claim funds: `npx hardhat claim --campaign-id 2 --address 0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512 --network localhost`

Expand Down
1 change: 1 addition & 0 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import "./tasks/pledge";
import "./tasks/allowance";
import "./tasks/claim";
import "./tasks/refund";
import "./tasks/cancel";

dotenv.config();

Expand Down
18 changes: 18 additions & 0 deletions tasks/cancel.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { task } from "hardhat/config";
import { utils } from "ethers";

task("cancel", "Cancel a campaign")
.addParam("address", "Crowdfunding contract address.")
.addParam("campaignId", "Campaign ID.")
.setAction(async (taskArgs, hre) => {
const { address, campaignId } = taskArgs;

const Crowdfunding = await hre.ethers.getContractFactory("Crowdfunding");
const crowdfunding = Crowdfunding.attach(address);

const cancel = await crowdfunding.cancel(utils.hexlify(+campaignId));

if (cancel) {
console.log("Campaign successfully cancelled");
}
});

0 comments on commit 7ae334d

Please sign in to comment.