Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

solidity-coverage hardhat plugin override the network object #624

Closed
wighawag opened this issue Apr 5, 2021 · 3 comments · Fixed by #647
Closed

solidity-coverage hardhat plugin override the network object #624

wighawag opened this issue Apr 5, 2021 · 3 comments · Fixed by #647

Comments

@wighawag
Copy link

wighawag commented Apr 5, 2021

This line override the hre.network object :

env.network = {
name: networkName,
config: networkConfig,
provider: provider,
isHardhatEVM: isHardhatEVM
}

This conflict with plugins that add field to the network object. (an example of such plugin is hardhat-deploy)

solidity-coverage should keep existing configuration.

@cgewecke
Copy link
Member

cgewecke commented Apr 5, 2021

Yes definitely, will fix.

@cgewecke
Copy link
Member

cgewecke commented Apr 6, 2021

@wighawag From your perspective, is the correct way to do this to merge with the existing properties on network?

e.g

env.network = Object.assign({ 
   name: networkName, 
   config: networkConfig, 
   provider: provider, 
   isHardhatEVM: isHardhatEVM 
 }, env.network) 

Or is this not enough? What modifications are you making on your end?

@wighawag
Copy link
Author

wighawag commented Apr 6, 2021

Yes that would work. I am adding extra field to the network object that deploy scripts can then used to perform different things depending on their values: {tags, live, saveDeployments}.

But there was actually a bigger issue for hardhat-deploy.
In a recent version I was accessing hre.network.provider at import time and storing it in a variable.
This caused hardhat-deploy to hang on that version, ignoring the fact that solidity-coverage replaced with a new one on task execution.

This is I think a general problem with hardhat plugin api where it is not clear for plugin at what point they get called in relation to other plugins, hence why I created : NomicFoundation/hardhat#1374

I fixed it in hardhat-deploy by storing a lazyObject to the provider. This allow solidity-coverage to replace it and hadhat-deploy to get the modified version when it is actually needed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants