Skip to content

Commit 416913e

Browse files
committed
feat: migration to hh v3
1 parent 6f22cda commit 416913e

3 files changed

Lines changed: 32 additions & 45 deletions

File tree

Lines changed: 23 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,28 @@
1-
import { HardhatRuntimeEnvironment } from "hardhat/types";
2-
import { DeployFunction } from "hardhat-deploy/types";
3-
import { Contract } from "ethers";
1+
import { artifacts, deployScript } from "../rocketh/deploy.js";
42

53
/**
6-
* Deploys a contract named "YourCollectible" using the deployer account and
7-
* constructor arguments set to the deployer address
4+
* Deploys a contract named "YourCollectible".
85
*
9-
* @param hre HardhatRuntimeEnvironment object.
6+
* On localhost, the deployer account is the one that comes with Hardhat, which is already funded.
7+
*
8+
* When deploying to live networks (e.g `yarn deploy --network sepolia`), the deployer account
9+
* should have sufficient balance to pay for the gas fees for contract creation.
10+
*
11+
* You can generate a random account with `yarn generate` which will fill DEPLOYER_PRIVATE_KEY_ENCRYPTED
12+
* in the .env file (used in hardhat.config.ts).
13+
* Run `yarn account` to check the deployer balance on every network.
1014
*/
11-
const deployYourCollectible: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
12-
/*
13-
On localhost, the deployer account is the one that comes with Hardhat, which is already funded.
14-
15-
When deploying to live networks (e.g `yarn deploy --network sepolia`), the deployer account
16-
should have sufficient balance to pay for the gas fees for contract creation.
17-
18-
You can generate a random account with `yarn generate` which will fill DEPLOYER_PRIVATE_KEY
19-
with a random private key in the .env file (then used on hardhat.config.ts)
20-
You can run the `yarn account` command to check your balance in every network.
21-
*/
22-
const { deployer } = await hre.getNamedAccounts();
23-
const { deploy } = hre.deployments;
24-
25-
await deploy("YourCollectible", {
26-
from: deployer,
27-
// Contract constructor arguments
28-
args: [],
29-
log: true,
30-
// autoMine: can be passed to the deploy function to make the deployment process faster on local networks by
31-
// automatically mining the contract deployment transaction. There is no effect on live networks.
32-
autoMine: true,
33-
});
34-
35-
// Get the deployed contract to interact with it after deploying.
36-
const yourCollectible = await hre.ethers.getContract<Contract>("YourCollectible", deployer);
37-
};
38-
39-
export default deployYourCollectible;
15+
export default deployScript(
16+
async ({ deploy, namedAccounts }) => {
17+
const { deployer } = namedAccounts;
4018

41-
// Tags are useful if you have multiple deploy files and only want to run one of them.
42-
// e.g. yarn deploy --tags YourCollectible
43-
deployYourCollectible.tags = ["YourCollectible"];
19+
await deploy("YourCollectible", {
20+
account: deployer,
21+
artifact: artifacts.YourCollectible,
22+
args: [],
23+
});
24+
},
25+
// Tags are useful if you have multiple deploy files and only want to run one of them.
26+
// e.g. yarn deploy --tags YourCollectible
27+
{ tags: ["YourCollectible"] },
28+
);

extension/packages/hardhat/test/YourCollectible.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,17 @@
22
// This script executes when you run 'yarn test'
33
//
44

5-
import { ethers } from "hardhat";
5+
import { network } from "hardhat";
66
import { expect } from "chai";
7-
import { YourCollectible } from "../typechain-types";
7+
import type { YourCollectible } from "../types/ethers-contracts/index.js";
88

99
describe("🚩 Challenge: 🎟 Tokenization 🤓", function () {
1010
let myContract: YourCollectible;
11+
let ethers: Awaited<ReturnType<typeof network.create>>["ethers"];
12+
13+
before(async function () {
14+
({ ethers } = await network.create());
15+
});
1116

1217
describe("YourCollectible", function () {
1318
const contractAddress = process.env.CONTRACT_ADDRESS;
@@ -21,8 +26,8 @@ describe("🚩 Challenge: 🎟 Tokenization 🤓", function () {
2126
}
2227

2328
it("Should deploy the contract", async function () {
24-
const YourCollectible = await ethers.getContractFactory(contractArtifact);
25-
myContract = await YourCollectible.deploy();
29+
const YourCollectibleFactory = await ethers.getContractFactory(contractArtifact);
30+
myContract = (await YourCollectibleFactory.deploy()) as unknown as YourCollectible;
2631
console.log("\t", " 🛰 Contract deployed on", await myContract.getAddress());
2732
});
2833

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

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

0 commit comments

Comments
 (0)