Skip to content

Commit 7ff36fa

Browse files
committed
feat: migration to hh v3
1 parent d59c7b6 commit 7ff36fa

4 files changed

Lines changed: 43 additions & 50 deletions

File tree

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,17 @@
1-
import { HardhatRuntimeEnvironment } from "hardhat/types";
2-
import { DeployFunction } from "hardhat-deploy/types";
1+
import { artifacts, deployScript } from "../rocketh/deploy.js";
32

43
/**
54
* Deploys a contract named "FundingRecipient" using the deployer account.
6-
*
7-
* @param hre HardhatRuntimeEnvironment object.
85
*/
9-
const deployFundingRecipient: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
10-
const { deployer } = await hre.getNamedAccounts();
11-
const { deploy } = hre.deployments;
6+
export default deployScript(
7+
async ({ deploy, namedAccounts }) => {
8+
const { deployer } = namedAccounts;
129

13-
await deploy("FundingRecipient", {
14-
from: deployer,
15-
log: true,
16-
autoMine: true,
17-
});
18-
};
19-
20-
export default deployFundingRecipient;
21-
22-
deployFundingRecipient.tags = ["FundingRecipient"];
10+
await deploy("FundingRecipient", {
11+
account: deployer,
12+
artifact: artifacts.FundingRecipient,
13+
args: [],
14+
});
15+
},
16+
{ tags: ["FundingRecipient"] },
17+
);
Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,19 @@
1-
import { HardhatRuntimeEnvironment } from "hardhat/types";
2-
import { DeployFunction } from "hardhat-deploy/types";
1+
import { artifacts, deployScript } from "../rocketh/deploy.js";
32

43
/**
54
* Deploys a contract named "CrowdFund" using the deployer account.
6-
*
7-
* @param hre HardhatRuntimeEnvironment object.
85
*/
9-
const deployCrowdFund: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
10-
const { deployer } = await hre.getNamedAccounts();
11-
const { deploy, get } = hre.deployments;
6+
export default deployScript(
7+
async ({ deploy, get, namedAccounts }) => {
8+
const { deployer } = namedAccounts;
129

13-
const fundingRecipient = await get("FundingRecipient");
10+
const fundingRecipient = get("FundingRecipient");
1411

15-
await deploy("CrowdFund", {
16-
from: deployer,
17-
args: [fundingRecipient.address],
18-
log: true,
19-
autoMine: true,
20-
});
21-
};
22-
23-
export default deployCrowdFund;
24-
25-
deployCrowdFund.tags = ["CrowdFund"];
12+
await deploy("CrowdFund", {
13+
account: deployer,
14+
artifact: artifacts.CrowdFund,
15+
args: [fundingRecipient.address],
16+
});
17+
},
18+
{ tags: ["CrowdFund"] },
19+
);

extension/packages/hardhat/test/CrowdFund.ts

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
11
//
22
// This script executes when you run 'yarn test'
33
//
4-
import { ethers, network } from "hardhat";
4+
import { network } from "hardhat";
55
import { expect } from "chai";
6-
import { FundingRecipient, CrowdFund } from "../typechain-types";
6+
import type { FundingRecipient, CrowdFund } from "../types/ethers-contracts/index.js";
77

88
describe("🚩 Challenge: 📣 Crowdfunding App", function () {
9+
let ethers: Awaited<ReturnType<typeof network.create>>["ethers"];
10+
let provider: Awaited<ReturnType<typeof network.create>>["provider"];
11+
912
let fundingRecipient: FundingRecipient;
1013
let crowdFundContract: CrowdFund;
1114

15+
before(async function () {
16+
({ ethers, provider } = await network.create());
17+
});
18+
1219
describe("CrowdFund", function () {
1320
const contractAddress = process.env.CONTRACT_ADDRESS;
1421

@@ -22,10 +29,10 @@ describe("🚩 Challenge: 📣 Crowdfunding App", function () {
2229

2330
const deployContracts = async () => {
2431
const FundingRecipientFactory = await ethers.getContractFactory("FundingRecipient");
25-
fundingRecipient = (await FundingRecipientFactory.deploy()) as FundingRecipient;
32+
fundingRecipient = (await FundingRecipientFactory.deploy()) as unknown as FundingRecipient;
2633

2734
const CrowdFundFactory = await ethers.getContractFactory(contractArtifact);
28-
crowdFundContract = (await CrowdFundFactory.deploy(await fundingRecipient.getAddress())) as CrowdFund;
35+
crowdFundContract = (await CrowdFundFactory.deploy(await fundingRecipient.getAddress())) as unknown as CrowdFund;
2936
};
3037

3138
describe("Checkpoint 1: 🤝 Contributing 💵", function () {
@@ -139,7 +146,7 @@ describe("🚩 Challenge: 📣 Crowdfunding App", function () {
139146

140147
const writeStorageAt = async (slot: bigint, value: string) => {
141148
const slotHex = ethers.zeroPadValue(ethers.toBeHex(slot), 32);
142-
await network.provider.send("hardhat_setStorageAt", [target, slotHex, value]);
149+
await provider.request({ method: "hardhat_setStorageAt", params: [target, slotHex, value] });
143150
};
144151

145152
const hexToBytes32 = (hex: string) => {
@@ -265,8 +272,8 @@ describe("🚩 Challenge: 📣 Crowdfunding App", function () {
265272
const t1 = await crowdFundContract.timeLeft();
266273
expect(Number(t1)).to.be.greaterThan(0);
267274

268-
await network.provider.send("evm_increaseTime", [5]);
269-
await network.provider.send("evm_mine");
275+
await provider.request({ method: "evm_increaseTime", params: [5] });
276+
await provider.request({ method: "evm_mine" });
270277

271278
const t2 = await crowdFundContract.timeLeft();
272279
expect(Number(t2)).to.be.lessThan(Number(t1));
@@ -283,8 +290,8 @@ describe("🚩 Challenge: 📣 Crowdfunding App", function () {
283290
const amount = ethers.parseEther("1");
284291
await crowdFundContract.contribute({ value: amount });
285292

286-
await network.provider.send("evm_increaseTime", [72 * 3600]);
287-
await network.provider.send("evm_mine");
293+
await provider.request({ method: "evm_increaseTime", params: [72 * 3600] });
294+
await provider.request({ method: "evm_mine" });
288295

289296
const timeLeft2 = await crowdFundContract.timeLeft();
290297
expect(
@@ -316,8 +323,8 @@ describe("🚩 Challenge: 📣 Crowdfunding App", function () {
316323
value: ethers.parseEther("0.001"),
317324
});
318325

319-
await network.provider.send("evm_increaseTime", [72 * 3600]);
320-
await network.provider.send("evm_mine");
326+
await provider.request({ method: "evm_increaseTime", params: [72 * 3600] });
327+
await provider.request({ method: "evm_mine" });
321328

322329
await crowdFundContract.execute();
323330

extension/packages/nextjs/next.config.ts.args.mjs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,4 @@ export const configOverrides = {
22
typescript: {
33
ignoreBuildErrors: true,
44
},
5-
eslint: {
6-
ignoreDuringBuilds: true,
7-
},
85
};

0 commit comments

Comments
 (0)