Closed fabianschu closed 1 year ago
For that issue you currently need to install hardhat-deploy-ethers as alias.
See https://github.com/wighawag/hardhat-deploy-ethers#installation
I'm the future (waiting for some changes in hardhat itself) this will hopefully not be required anymore
I created #13 because I'm not sure how to follow that installation advice. Seems like that breaks also.
Sorry, the code that I had posted was not correct. In fact I had installed hardhat-deploy-ethers as alias. I updated the code for the second package.json. Still, the problem persists. @wighawag
@fabianschu can you try with an alias to a specific version of hardhat-deploy-ethers ? like npm:hardhat-deploy-ethers@0.3.0-beta.10
@wighawag I tried that. Here is my dependencies:
"devDependencies": {
"@nomiclabs/hardhat-ethers": "npm:hardhat-deploy-ethers@^0.3.0-beta.10",
"@nomiclabs/hardhat-waffle": "^2.0.1",
"chai": "^4.3.4",
"ethereum-waffle": "^3.4.0",
"ethers": "^5.4.1",
"hardhat": "^2.4.1",
"hardhat-deploy": "^0.7.0-beta.46",
"hardhat-gas-reporter": "^1.0.4",
"solhint": "^3.3.3"
},
"dependencies": {
"@openzeppelin/contracts": "^4.2.0",
"eslint": "^7.30.0",
"solidity-coverage": "^0.7.16"
}
I first installed hardhat-deploy-ethers by adding this line "@nomiclabs/hardhat-ethers": "npm:hardhat-deploy-ethers@^0.3.0-beta.10",
to the package.json, then npm i
. Then I installed hardhat-waffle by running npm install -D @nomiclabs/hardhat-waffle
. I got the folliwing error:
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: XXXXX@1.0.0
npm ERR! Found: @nomiclabs/hardhat-ethers@0.3.0-beta.10
npm ERR! node_modules/@nomiclabs/hardhat-ethers
npm ERR! dev @nomiclabs/hardhat-ethers@"npm:hardhat-deploy-ethers@^0.3.0-beta.10" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer @nomiclabs/hardhat-ethers@"^2.0.0" from @nomiclabs/hardhat-waffle@2.0.1
npm ERR! node_modules/@nomiclabs/hardhat-waffle
npm ERR! dev @nomiclabs/hardhat-waffle@"*" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See /Users/XXXXX/.npm/eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/XXXXXX/.npm/_logs/2021-07-21T08_19_51_758Z-debug.log
I force-installed hardhat-waffle npm install -D @nomiclabs/hardhat-waffle --force
and now I have access to the getContract
function and tests are still working. So, it seems to work, but it feels a bit shaky. Upon force-installing hardhat-waffle I got this message:
npm WARN using --force Recommended protections disabled.
npm WARN ERESOLVE overriding peer dependency
npm WARN Found: @nomiclabs/hardhat-ethers@0.3.0-beta.10
npm WARN node_modules/@nomiclabs/hardhat-ethers
npm WARN dev @nomiclabs/hardhat-ethers@"npm:hardhat-deploy-ethers@^0.3.0-beta.10" from the root project
npm WARN
npm WARN Could not resolve dependency:
npm WARN peer @nomiclabs/hardhat-ethers@"^2.0.0" from @nomiclabs/hardhat-waffle@2.0.1
npm WARN node_modules/@nomiclabs/hardhat-waffle
npm WARN dev @nomiclabs/hardhat-waffle@"*" from the root project
Fun fact: with yarn, these dependencies can be installed without an error and both hardhat-deploy-ethers and hardhat-waffle seem to work.
"devDependencies": {
"@nomiclabs/hardhat-ethers": "npm:hardhat-deploy-ethers@^0.3.0-beta.10",
"@nomiclabs/hardhat-waffle": "^2.0.1",
"chai": "^4.3.4",
"ethereum-waffle": "^3.4.0",
"ethers": "^5.4.1",
"hardhat": "^2.4.1",
"hardhat-deploy": "^0.7.11",
"hardhat-gas-reporter": "^1.0.4",
"solhint": "^3.3.3"
},
"dependencies": {
"@openzeppelin/contracts": "^4.2.0",
"eslint": "^7.30.0",
"solidity-coverage": "^0.7.16"
}
Ran into the same problem. Took me quite a while before I found this but @fabianschu's suggestion to use Yarn AND the specific version reference fixed it.
+1 the suggestion of yarn + specific version (copypasted full line "@nomiclabs/hardhat-ethers": "npm:hardhat-deploy-ethers@^0.3.0-beta.10",
) worked for me
For that issue you currently need to install hardhat-deploy-ethers as alias.
See https://github.com/wighawag/hardhat-deploy-ethers#installation
I'm the future (waiting for some changes in hardhat itself) this will hopefully not be required anymore
do you have an idea/time horizon when that will happen?
do you have an idea/time horizon when that will happen?
Best to ask hardhat team there : https://github.com/nomiclabs/hardhat/issues/1040 :)
@jrfrantz commented on September 8, 2021 10:38 PM:
+1 the suggestion of yarn + specific version (copypasted full line
"@nomiclabs/hardhat-ethers": "npm:hardhat-deploy-ethers@^0.3.0-beta.10",
) worked for me
Does this work for anyone with the latest ^0.3.0-beta.13
?
I think I'm possibly seeing the same issue with hardhat-ethernal
, which also hardcodes its dependency with @nomiclabs/hardhat-ethers
.
i think using npm running this command might help npm install -D @nomiclabs/hardhat-ethers@npm:hardhat-deploy-ethers ethers
it worked for me.
Same problem with https://github.com/Tenderly/hardhat-tenderly which hardcodes @nomiclabs/hardhat-ethers . I will open an issue in their repo. How should they go about fixing this? How do they not hardcode a version of hardhat-ethers that gives us freedom to use hardhat-deploy-ethers instead?
I solved this problem using the solution suggested in this comment https://github.com/Tenderly/hardhat-tenderly/issues/51#issuecomment-1199129116
I solved this problem using the solution suggested in this comment Tenderly/hardhat-tenderly#51 (comment)
first it didn't work for me. But I re-checked to have similar dependencies as in the scaffold-eth repo and now it solved it for me
hardhat-deploy-ethers@next has been released Please, try it out.
It is now an extension to hardhat-ethers so you need both
But note that that new version do not support external artifact if you were using them
can you help with this, where is this "hardhat-deploy-ethers@next" version?
the latest is https://www.npmjs.com/package/hardhat-deploy-ethers/v/0.4.0-next.1
you can use the tag when installing
npm i -D hardhat-deploy-ethers@next
the latest is https://www.npmjs.com/package/hardhat-deploy-ethers/v/0.4.0-next.1
you can use the tag when installing
npm i -D hardhat-deploy-ethers@next
how come on GitHub there are no tags for those next releases? https://github.com/wighawag/hardhat-deploy-ethers/tags
how come on GitHub there are no tags for those next releases? https://github.com/wighawag/hardhat-deploy-ethers/tags
I am just not very good at making sure they are tagged :)
I was searching there 2 months ago, then again today, couldn't find it and was thinking WTF am I missing :D
I'm having a simple hardhat project. I'm using the instructions from this issue https://github.com/wighawag/hardhat-deploy-ethers/issues/1 to circumvent the error
'getContract' function does not exist on HardhatRuntimeEnvironment.ethers
. My package.json looks as follows and everything works fine:So, I want to use the
hardhat-waffle
plugin. I donpm i -D @nomiclabs/hardhat-ethers
. As a result I cannot usegetContract
, because I get the error'getContract' function does not exist on HardhatRuntimeEnvironment.ethers
again. My package.json looks now looks like this:Any ideas how I can fix this? cheers