hardhat 3.10.0 → 3.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +23 -0
- package/dist/src/internal/builtin-plugins/solidity/build-system/build-system.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/build-system.js +11 -7
- package/dist/src/internal/builtin-plugins/solidity/build-system/build-system.js.map +1 -1
- package/dist/src/internal/cli/init/init.d.ts +3 -8
- package/dist/src/internal/cli/init/init.d.ts.map +1 -1
- package/dist/src/internal/cli/init/init.js +9 -27
- package/dist/src/internal/cli/init/init.js.map +1 -1
- package/dist/src/internal/cli/init/prompt.d.ts +0 -1
- package/dist/src/internal/cli/init/prompt.d.ts.map +1 -1
- package/dist/src/internal/cli/init/prompt.js +0 -24
- package/dist/src/internal/cli/init/prompt.js.map +1 -1
- package/dist/src/internal/cli/init/template.d.ts +1 -1
- package/dist/src/internal/cli/init/template.d.ts.map +1 -1
- package/dist/src/internal/cli/init/template.js +2 -2
- package/dist/src/internal/cli/init/template.js.map +1 -1
- package/dist/src/internal/cli/main.js +1 -1
- package/dist/src/internal/cli/main.js.map +1 -1
- package/dist/src/internal/cli/telemetry/analytics/analytics.d.ts +1 -1
- package/dist/src/internal/cli/telemetry/analytics/analytics.d.ts.map +1 -1
- package/dist/src/internal/cli/telemetry/analytics/analytics.js +2 -2
- package/dist/src/internal/cli/telemetry/analytics/analytics.js.map +1 -1
- package/dist/src/internal/cli/telemetry/analytics/types.d.ts +1 -1
- package/dist/src/internal/cli/telemetry/analytics/types.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/internal/builtin-plugins/solidity/build-system/build-system.ts +13 -6
- package/src/internal/cli/init/init.ts +4 -38
- package/src/internal/cli/init/prompt.ts +0 -31
- package/src/internal/cli/init/template.ts +2 -4
- package/src/internal/cli/main.ts +1 -1
- package/src/internal/cli/telemetry/analytics/analytics.ts +1 -2
- package/src/internal/cli/telemetry/analytics/types.ts +1 -1
- package/templates/{hardhat-3/01-node-test-runner-viem → 01-node-test-runner-viem}/package.json +1 -1
- package/templates/{hardhat-3/02-mocha-ethers → 02-mocha-ethers}/package.json +1 -1
- package/templates/{hardhat-3/03-minimal → 03-minimal}/package.json +1 -1
- package/templates/hardhat-2/01-mocha-ethers-js/README.md +0 -13
- package/templates/hardhat-2/01-mocha-ethers-js/contracts/Lock.sol +0 -34
- package/templates/hardhat-2/01-mocha-ethers-js/gitignore +0 -17
- package/templates/hardhat-2/01-mocha-ethers-js/hardhat.config.js +0 -6
- package/templates/hardhat-2/01-mocha-ethers-js/ignition/modules/Lock.js +0 -18
- package/templates/hardhat-2/01-mocha-ethers-js/package.json +0 -23
- package/templates/hardhat-2/01-mocha-ethers-js/test/Lock.js +0 -126
- package/templates/hardhat-2/02-mocha-ethers-js-esm/README.md +0 -13
- package/templates/hardhat-2/02-mocha-ethers-js-esm/contracts/Lock.sol +0 -34
- package/templates/hardhat-2/02-mocha-ethers-js-esm/gitignore +0 -17
- package/templates/hardhat-2/02-mocha-ethers-js-esm/hardhat.config.cjs +0 -6
- package/templates/hardhat-2/02-mocha-ethers-js-esm/ignition/modules/Lock.js +0 -18
- package/templates/hardhat-2/02-mocha-ethers-js-esm/package.json +0 -24
- package/templates/hardhat-2/02-mocha-ethers-js-esm/test/Lock.js +0 -128
- package/templates/hardhat-2/03-mocha-ethers-ts/README.md +0 -13
- package/templates/hardhat-2/03-mocha-ethers-ts/contracts/Lock.sol +0 -34
- package/templates/hardhat-2/03-mocha-ethers-ts/gitignore +0 -17
- package/templates/hardhat-2/03-mocha-ethers-ts/hardhat.config.ts +0 -8
- package/templates/hardhat-2/03-mocha-ethers-ts/ignition/modules/Lock.ts +0 -20
- package/templates/hardhat-2/03-mocha-ethers-ts/package.json +0 -28
- package/templates/hardhat-2/03-mocha-ethers-ts/test/Lock.ts +0 -127
- package/templates/hardhat-2/03-mocha-ethers-ts/tsconfig.json +0 -11
- package/templates/hardhat-2/04-mocha-viem-ts/README.md +0 -13
- package/templates/hardhat-2/04-mocha-viem-ts/contracts/Lock.sol +0 -34
- package/templates/hardhat-2/04-mocha-viem-ts/gitignore +0 -17
- package/templates/hardhat-2/04-mocha-viem-ts/hardhat.config.ts +0 -8
- package/templates/hardhat-2/04-mocha-viem-ts/ignition/modules/Lock.ts +0 -21
- package/templates/hardhat-2/04-mocha-viem-ts/package.json +0 -25
- package/templates/hardhat-2/04-mocha-viem-ts/test/Lock.ts +0 -134
- package/templates/hardhat-2/04-mocha-viem-ts/tsconfig.json +0 -11
- package/templates/hardhat-2/05-empty-hardhat-config-js/hardhat.config.js +0 -4
- package/templates/hardhat-2/05-empty-hardhat-config-js/package.json +0 -9
- /package/templates/{hardhat-3/01-node-test-runner-viem → 01-node-test-runner-viem}/AGENTS.md +0 -0
- /package/templates/{hardhat-3/01-node-test-runner-viem → 01-node-test-runner-viem}/README.md +0 -0
- /package/templates/{hardhat-3/01-node-test-runner-viem → 01-node-test-runner-viem}/contracts/Counter.sol +0 -0
- /package/templates/{hardhat-3/01-node-test-runner-viem → 01-node-test-runner-viem}/contracts/Counter.t.sol +0 -0
- /package/templates/{hardhat-3/01-node-test-runner-viem → 01-node-test-runner-viem}/gitignore +0 -0
- /package/templates/{hardhat-3/01-node-test-runner-viem → 01-node-test-runner-viem}/hardhat.config.ts +0 -0
- /package/templates/{hardhat-3/01-node-test-runner-viem → 01-node-test-runner-viem}/ignition/modules/Counter.ts +0 -0
- /package/templates/{hardhat-3/01-node-test-runner-viem → 01-node-test-runner-viem}/scripts/send-op-tx.ts +0 -0
- /package/templates/{hardhat-3/01-node-test-runner-viem → 01-node-test-runner-viem}/test/Counter.ts +0 -0
- /package/templates/{hardhat-3/01-node-test-runner-viem → 01-node-test-runner-viem}/tsconfig.json +0 -0
- /package/templates/{hardhat-3/02-mocha-ethers → 02-mocha-ethers}/AGENTS.md +0 -0
- /package/templates/{hardhat-3/02-mocha-ethers → 02-mocha-ethers}/README.md +0 -0
- /package/templates/{hardhat-3/02-mocha-ethers → 02-mocha-ethers}/contracts/Counter.sol +0 -0
- /package/templates/{hardhat-3/02-mocha-ethers → 02-mocha-ethers}/contracts/Counter.t.sol +0 -0
- /package/templates/{hardhat-3/02-mocha-ethers → 02-mocha-ethers}/gitignore +0 -0
- /package/templates/{hardhat-3/02-mocha-ethers → 02-mocha-ethers}/hardhat.config.ts +0 -0
- /package/templates/{hardhat-3/02-mocha-ethers → 02-mocha-ethers}/ignition/modules/Counter.ts +0 -0
- /package/templates/{hardhat-3/02-mocha-ethers → 02-mocha-ethers}/scripts/send-op-tx.ts +0 -0
- /package/templates/{hardhat-3/02-mocha-ethers → 02-mocha-ethers}/test/Counter.ts +0 -0
- /package/templates/{hardhat-3/02-mocha-ethers → 02-mocha-ethers}/tsconfig.json +0 -0
- /package/templates/{hardhat-3/03-minimal → 03-minimal}/README.md +0 -0
- /package/templates/{hardhat-3/03-minimal → 03-minimal}/gitignore +0 -0
- /package/templates/{hardhat-3/03-minimal → 03-minimal}/hardhat.config.ts +0 -0
- /package/templates/{hardhat-3/03-minimal → 03-minimal}/tsconfig.json +0 -0
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
time,
|
|
3
|
-
loadFixture,
|
|
4
|
-
} from "@nomicfoundation/hardhat-toolbox-viem/network-helpers";
|
|
5
|
-
import { expect } from "chai";
|
|
6
|
-
import hre from "hardhat";
|
|
7
|
-
import { getAddress, parseGwei } from "viem";
|
|
8
|
-
|
|
9
|
-
describe("Lock", function () {
|
|
10
|
-
// We define a fixture to reuse the same setup in every test.
|
|
11
|
-
// We use loadFixture to run this setup once, snapshot that state,
|
|
12
|
-
// and reset Hardhat Network to that snapshot in every test.
|
|
13
|
-
async function deployOneYearLockFixture() {
|
|
14
|
-
const ONE_YEAR_IN_SECS = 365 * 24 * 60 * 60;
|
|
15
|
-
|
|
16
|
-
const lockedAmount = parseGwei("1");
|
|
17
|
-
const unlockTime = BigInt((await time.latest()) + ONE_YEAR_IN_SECS);
|
|
18
|
-
|
|
19
|
-
// Contracts are deployed using the first signer/account by default
|
|
20
|
-
const [owner, otherAccount] = await hre.viem.getWalletClients();
|
|
21
|
-
|
|
22
|
-
const lock = await hre.viem.deployContract("Lock", [unlockTime], {
|
|
23
|
-
value: lockedAmount,
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
const publicClient = await hre.viem.getPublicClient();
|
|
27
|
-
|
|
28
|
-
return {
|
|
29
|
-
lock,
|
|
30
|
-
unlockTime,
|
|
31
|
-
lockedAmount,
|
|
32
|
-
owner,
|
|
33
|
-
otherAccount,
|
|
34
|
-
publicClient,
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
describe("Deployment", function () {
|
|
39
|
-
it("Should set the right unlockTime", async function () {
|
|
40
|
-
const { lock, unlockTime } = await loadFixture(deployOneYearLockFixture);
|
|
41
|
-
|
|
42
|
-
expect(await lock.read.unlockTime()).to.equal(unlockTime);
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it("Should set the right owner", async function () {
|
|
46
|
-
const { lock, owner } = await loadFixture(deployOneYearLockFixture);
|
|
47
|
-
|
|
48
|
-
expect(await lock.read.owner()).to.equal(
|
|
49
|
-
getAddress(owner.account.address),
|
|
50
|
-
);
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
it("Should receive and store the funds to lock", async function () {
|
|
54
|
-
const { lock, lockedAmount, publicClient } = await loadFixture(
|
|
55
|
-
deployOneYearLockFixture,
|
|
56
|
-
);
|
|
57
|
-
|
|
58
|
-
expect(
|
|
59
|
-
await publicClient.getBalance({
|
|
60
|
-
address: lock.address,
|
|
61
|
-
}),
|
|
62
|
-
).to.equal(lockedAmount);
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
it("Should fail if the unlockTime is not in the future", async function () {
|
|
66
|
-
// We don't use the fixture here because we want a different deployment
|
|
67
|
-
const latestTime = BigInt(await time.latest());
|
|
68
|
-
await expect(
|
|
69
|
-
hre.viem.deployContract("Lock", [latestTime], {
|
|
70
|
-
value: 1n,
|
|
71
|
-
}),
|
|
72
|
-
).to.be.rejectedWith("Unlock time should be in the future");
|
|
73
|
-
});
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
describe("Withdrawals", function () {
|
|
77
|
-
describe("Validations", function () {
|
|
78
|
-
it("Should revert with the right error if called too soon", async function () {
|
|
79
|
-
const { lock } = await loadFixture(deployOneYearLockFixture);
|
|
80
|
-
|
|
81
|
-
await expect(lock.write.withdraw()).to.be.rejectedWith(
|
|
82
|
-
"You can't withdraw yet",
|
|
83
|
-
);
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
it("Should revert with the right error if called from another account", async function () {
|
|
87
|
-
const { lock, unlockTime, otherAccount } = await loadFixture(
|
|
88
|
-
deployOneYearLockFixture,
|
|
89
|
-
);
|
|
90
|
-
|
|
91
|
-
// We can increase the time in Hardhat Network
|
|
92
|
-
await time.increaseTo(unlockTime);
|
|
93
|
-
|
|
94
|
-
// We retrieve the contract with a different account to send a transaction
|
|
95
|
-
const lockAsOtherAccount = await hre.viem.getContractAt(
|
|
96
|
-
"Lock",
|
|
97
|
-
lock.address,
|
|
98
|
-
{ client: { wallet: otherAccount } },
|
|
99
|
-
);
|
|
100
|
-
await expect(lockAsOtherAccount.write.withdraw()).to.be.rejectedWith(
|
|
101
|
-
"You aren't the owner",
|
|
102
|
-
);
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
it("Shouldn't fail if the unlockTime has arrived and the owner calls it", async function () {
|
|
106
|
-
const { lock, unlockTime } = await loadFixture(
|
|
107
|
-
deployOneYearLockFixture,
|
|
108
|
-
);
|
|
109
|
-
|
|
110
|
-
// Transactions are sent using the first signer by default
|
|
111
|
-
await time.increaseTo(unlockTime);
|
|
112
|
-
|
|
113
|
-
await expect(lock.write.withdraw()).to.be.fulfilled;
|
|
114
|
-
});
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
describe("Events", function () {
|
|
118
|
-
it("Should emit an event on withdrawals", async function () {
|
|
119
|
-
const { lock, unlockTime, lockedAmount, publicClient } =
|
|
120
|
-
await loadFixture(deployOneYearLockFixture);
|
|
121
|
-
|
|
122
|
-
await time.increaseTo(unlockTime);
|
|
123
|
-
|
|
124
|
-
const hash = await lock.write.withdraw();
|
|
125
|
-
await publicClient.waitForTransactionReceipt({ hash });
|
|
126
|
-
|
|
127
|
-
// get the withdrawal events in the latest block
|
|
128
|
-
const withdrawalEvents = await lock.getEvents.Withdrawal();
|
|
129
|
-
expect(withdrawalEvents).to.have.lengthOf(1);
|
|
130
|
-
expect(withdrawalEvents[0].args.amount).to.equal(lockedAmount);
|
|
131
|
-
});
|
|
132
|
-
});
|
|
133
|
-
});
|
|
134
|
-
});
|
/package/templates/{hardhat-3/01-node-test-runner-viem → 01-node-test-runner-viem}/AGENTS.md
RENAMED
|
File without changes
|
/package/templates/{hardhat-3/01-node-test-runner-viem → 01-node-test-runner-viem}/README.md
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/templates/{hardhat-3/01-node-test-runner-viem → 01-node-test-runner-viem}/gitignore
RENAMED
|
File without changes
|
/package/templates/{hardhat-3/01-node-test-runner-viem → 01-node-test-runner-viem}/hardhat.config.ts
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/templates/{hardhat-3/01-node-test-runner-viem → 01-node-test-runner-viem}/test/Counter.ts
RENAMED
|
File without changes
|
/package/templates/{hardhat-3/01-node-test-runner-viem → 01-node-test-runner-viem}/tsconfig.json
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/templates/{hardhat-3/02-mocha-ethers → 02-mocha-ethers}/ignition/modules/Counter.ts
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|