Skip to content

Commit 28ba70f

Browse files
authored
Merge branch 'master' into remove-buidler-stuff
2 parents 4d822fd + b56f209 commit 28ba70f

File tree

7 files changed

+697
-204
lines changed

7 files changed

+697
-204
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Changelog
22

3+
0.8.4 / 2023-07-04
4+
==================
5+
* Update solidity-parser to 0.16.0 (https://github.com/sc-forks/solidity-coverage/issues/802)
6+
7+
0.8.3 / 2023-06-22
8+
==================
9+
* Updates for Hardhat v2.15.0 (https://github.com/sc-forks/solidity-coverage/pull/796)
10+
311
0.8.1 / 2022-09-06
412
===================
513
* Restore web3-utils (https://github.com/sc-forks/solidity-coverage/issues/743)

lib/api.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,10 +279,17 @@ class API {
279279
}
280280

281281
// Hardhat
282-
attachToHardhatVM(provider){
282+
async attachToHardhatVM(provider){
283283
const self = this;
284284
this.collector = new DataCollector(this.instrumenter.instrumentationData);
285285

286+
if ('init' in provider) {
287+
// Newer versions of Hardhat initialize the provider lazily, so we need to
288+
// call provider.init() explicitly. This is a no-op if the provider is
289+
// already initialized.
290+
await provider.init();
291+
}
292+
286293
let cur = provider;
287294

288295
// Go down to core HardhatNetworkProvider

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "solidity-coverage",
3-
"version": "0.8.1",
3+
"version": "0.8.4",
44
"description": "",
55
"main": "plugins/nomiclabs.plugin.js",
66
"bin": {
@@ -25,7 +25,7 @@
2525
"license": "ISC",
2626
"dependencies": {
2727
"@ethersproject/abi": "^5.0.9",
28-
"@solidity-parser/parser": "^0.14.1",
28+
"@solidity-parser/parser": "^0.16.0",
2929
"chalk": "^2.4.2",
3030
"death": "^1.1.0",
3131
"detect-port": "^1.3.0",
@@ -36,7 +36,7 @@
3636
"globby": "^10.0.1",
3737
"jsonschema": "^1.2.4",
3838
"lodash": "^4.17.15",
39-
"mocha": "7.1.2",
39+
"mocha": "10.2.0",
4040
"node-emoji": "^1.10.0",
4141
"pify": "^4.0.1",
4242
"recursive-readdir": "^2.2.2",
@@ -56,7 +56,7 @@
5656
"ethereum-waffle": "^3.4.0",
5757
"ethers": "^5.5.3",
5858
"ganache-cli": "6.12.2",
59-
"hardhat": "^2.11.0",
59+
"hardhat": "^2.17.3",
6060
"hardhat-gas-reporter": "^1.0.1",
6161
"nyc": "^14.1.1",
6262
"solc": "^0.7.5"

plugins/hardhat.plugin.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -198,19 +198,19 @@ task("coverage", "Generates a code coverage report for tests")
198198
// ==============
199199
// Server launch
200200
// ==============
201-
let network = nomiclabsUtils.setupHardhatNetwork(env, api, ui);
201+
let network = await nomiclabsUtils.setupHardhatNetwork(env, api, ui);
202202

203203
if (network.isHardhatEVM){
204204
accounts = await utils.getAccountsHardhat(network.provider);
205205
nodeInfo = await utils.getNodeInfoHardhat(network.provider);
206206

207207
// Note: this only works if the reset block number is before any transactions have fired on the fork.
208208
// e.g you cannot fork at block 1, send some txs (blocks 2,3,4) and reset to block 2
209-
env.network.provider.on(HARDHAT_NETWORK_RESET_EVENT, () => {
210-
api.attachToHardhatVM(env.network.provider);
209+
env.network.provider.on(HARDHAT_NETWORK_RESET_EVENT, async () => {
210+
await api.attachToHardhatVM(env.network.provider);
211211
});
212212

213-
api.attachToHardhatVM(network.provider);
213+
await api.attachToHardhatVM(network.provider);
214214

215215
ui.report('hardhat-network', [
216216
nodeInfo.split('/')[1],

plugins/resources/nomiclabs.utils.js

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,14 @@ function normalizeConfig(config, args={}){
4949
return config;
5050
}
5151

52-
function setupHardhatNetwork(env, api, ui){
52+
async function setupHardhatNetwork(env, api, ui){
53+
const hardhatPackage = require('hardhat/package.json');
5354
const { createProvider } = require("hardhat/internal/core/providers/construction");
5455
const { HARDHAT_NETWORK_NAME } = require("hardhat/plugins")
5556

57+
// after 2.15.0, the internal createProvider function has a different signature
58+
const newCreateProviderSignature = semver.satisfies(hardhatPackage.version, "^2.15.0");
59+
5660
let provider, networkName, networkConfig;
5761
let isHardhatEVM = false;
5862

@@ -65,12 +69,20 @@ function setupHardhatNetwork(env, api, ui){
6569
networkConfig = env.network.config;
6670
configureHardhatEVMGas(networkConfig, api);
6771

68-
provider = createProvider(
69-
networkName,
70-
networkConfig,
71-
env.config.paths,
72-
env.artifacts,
73-
)
72+
if (newCreateProviderSignature) {
73+
provider = await createProvider(
74+
env.config,
75+
networkName,
76+
env.artifacts,
77+
)
78+
} else {
79+
provider = createProvider(
80+
networkName,
81+
networkConfig,
82+
env.config.paths,
83+
env.artifacts,
84+
)
85+
}
7486

7587
// HttpProvider
7688
} else {
@@ -80,7 +92,12 @@ function setupHardhatNetwork(env, api, ui){
8092
networkConfig = env.config.networks[networkName]
8193
configureNetworkGas(networkConfig, api);
8294
configureHttpProvider(networkConfig, api, ui)
83-
provider = createProvider(networkName, networkConfig);
95+
96+
if (newCreateProviderSignature) {
97+
provider = await createProvider(env.config, networkName);
98+
} else {
99+
provider = createProvider(networkName, networkConfig);
100+
}
84101
}
85102

86103
return configureNetworkEnv(

scripts/run-zeppelin.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ cd openzeppelin-contracts
2828
echo ">>>>> npm install"
2929
npm install
3030

31-
# Use HH Merge version
32-
npm install hardhat@2.11.0 --save-dev
31+
# Use HH latest
32+
npm install hardhat@latest --save-dev
3333

3434
echo ">>>>> npm uninstall solidity-coverage --save-dev"
3535
npm uninstall solidity-coverage --save-dev

0 commit comments

Comments
 (0)