Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions plugins/resources/nomiclabs.utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ function configureNetworkEnv(env, networkName, networkConfig, provider, isHardha
env.config.defaultNetwork = networkName;

env.network = {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fact that it still create a new object will cause issue with plugin that modify the network object before this is called.
It is better to simply modify the network object

Copy link
Author

@fredlacs fredlacs Jul 21, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm using the fork with this fork and seems to be working well with hardhat deploy :)

If they modify it before, it shouldn't be an issue since we first set all previous object values then only override the needed ones ...env.network.
If you meant using Object.assign I believe the main difference would only be that setters are called on the object. According to a random SO answer: "spread operator will not copy the the source object’s prototype to the target object"

How would you suggest this be implemented? Glad to iterate on it or take a PR heh

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Plugins could have copied the reference to hre.network before and will later modify an unrelated object. Modifying the network object would be safer. I proposed this in that comment: wighawag/hardhat-deploy#132 (comment)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Object.assign retains the reference to the original object too. I think that is more conventional. But simplicity is always good so maybe @wighawag solution of just doing inplace modifications (env.network.name = networkName etc.) is better.

...env.network,
name: networkName,
config: networkConfig,
provider: provider,
Expand Down