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

Dependency conflict with Hardhat V5 #201

Open
robhyrk opened this issue Jan 28, 2025 · 5 comments
Open

Dependency conflict with Hardhat V5 #201

robhyrk opened this issue Jan 28, 2025 · 5 comments

Comments

@robhyrk
Copy link

robhyrk commented Jan 28, 2025

Describe the bug
Cannot install if using Hardhat V5 due to deps conflict with Ethers v6

Reproduction steps

  1. npm install @defi-wonderland/smock

Expected behavior
Should install without error.

Screenshots

npm error code ERESOLVE
npm error ERESOLVE could not resolve
npm error
npm error While resolving: [email protected]
npm error Found: [email protected]
npm error node_modules/ethers
npm error   peer ethers@"^6.1.0" from @nomicfoundation/[email protected]
npm error   node_modules/@nomicfoundation/hardhat-chai-matchers
npm error     peer @nomicfoundation/hardhat-chai-matchers@"^2.0.0" from @nomicfoundation/[email protected]
npm error     node_modules/@nomicfoundation/hardhat-toolbox
npm error       dev @nomicfoundation/hardhat-toolbox@"^5.0.0" from the root project
npm error   peer ethers@"^6.1.0" from @nomicfoundation/[email protected]
npm error   node_modules/@nomicfoundation/hardhat-ethers
npm error     peer @nomicfoundation/hardhat-ethers@"^3.0.0" from @nomicfoundation/[email protected]
npm error     node_modules/@nomicfoundation/hardhat-chai-matchers
npm error       peer @nomicfoundation/hardhat-chai-matchers@"^2.0.0" from @nomicfoundation/[email protected]
npm error       node_modules/@nomicfoundation/hardhat-toolbox
npm error         dev @nomicfoundation/hardhat-toolbox@"^5.0.0" from the root project
npm error     peer @nomicfoundation/hardhat-ethers@"^3.0.4" from @nomicfoundation/[email protected]
npm error     node_modules/@nomicfoundation/hardhat-ignition-ethers
npm error       peer @nomicfoundation/hardhat-ignition-ethers@"^0.15.0" from @nomicfoundation/[email protected]
npm error       node_modules/@nomicfoundation/hardhat-toolbox
npm error         dev @nomicfoundation/hardhat-toolbox@"^5.0.0" from the root project
npm error     1 more (@nomicfoundation/hardhat-toolbox)
npm error   5 more (@nomicfoundation/hardhat-ignition-ethers, ...)
npm error
npm error Could not resolve dependency:
npm error dev @defi-wonderland/smock@"*" from the root project
npm error
npm error Conflicting peer dependency: [email protected]
npm error node_modules/ethers
npm error   peer ethers@"^5" from @defi-wonderland/[email protected]
npm error   node_modules/@defi-wonderland/smock
npm error     dev @defi-wonderland/smock@"*" from the root project
npm error
npm error Fix the upstream dependency conflict, or retry
npm error this command with --force or --legacy-peer-deps
npm error to accept an incorrect (and potentially broken) dependency resolution.

System Specs:

  • OS: Version 14.6.1
  • Package Version (or commit hash): 2.4.0
@robhyrk robhyrk changed the title Dependancy conflict with Hardhat V5 Dependency conflict with Hardhat V5 Jan 28, 2025
@0xteddybear
Copy link

Thanks for reporting this.
This package is indeed coupled to ethers v5 and supporting ethers v6 would require some refactoring and a major version change. We can get to it eventually, but can't promise anything in the short term.'

@blundin
Copy link

blundin commented Feb 6, 2025

Does anyone have advice for getting this to work? Any workarounds?

@0xteddybear
Copy link

Does anyone have advice for getting this to work? Any workarounds?

if you want to take care of this, we could review & merge it. While you could just edit the peer dependency specification and have npm install work, you'll find lots of errors down the line due to various API changes in ethers v5 vs v4.

The correct way to go about this would be as follows

  • update ethers devDependency in this project to v5, and probably a lot of others to make it work [1]
  • fix all tests so ethers invocations are compliant with the new API
  • use an existing project as a guinea pig to see if ^ miss anything
  • only after that, publish a release on NPM

[1]: I tried to asses the feasibility of this, and so far I had to edit many dependencies. I got it to the point where the project would compile IIRC, but tests crashed instantly, see patch below:

diff --git a/hardhat.config.ts b/hardhat.config.ts
index 5ab3210..11639a6 100644
--- a/hardhat.config.ts
+++ b/hardhat.config.ts
@@ -21,7 +21,7 @@ const config: HardhatUserConfig = {
   },
   typechain: {
     outDir: 'typechained',
-    target: 'ethers-v5',
+    target: 'ethers-v6',
   },
 };
 
diff --git a/package.json b/package.json
index f60e927..dd90d1e 100644
--- a/package.json
+++ b/package.json
@@ -63,10 +63,10 @@
   "devDependencies": {
     "@commitlint/cli": "12.1.4",
     "@commitlint/config-conventional": "12.1.4",
-    "@nomiclabs/hardhat-ethers": "2.0.2",
-    "@nomiclabs/hardhat-waffle": "2.0.1",
-    "@typechain/ethers-v5": "7.0.1",
-    "@typechain/hardhat": "2.0.2",
+    "@nomiclabs/hardhat-ethers": "2.2.3",
+    "@nomiclabs/hardhat-waffle": "2.0.6",
+    "@typechain/ethers-v6": "0.5.1",
+    "@typechain/hardhat": "9.1.0",
     "@types/chai": "4.2.18",
     "@types/chai-as-promised": "7.1.5",
     "@types/debug": "^4.1.4",
@@ -82,7 +82,7 @@
     "chai-as-promised": "7.1.1",
     "cross-env": "7.0.3",
     "ethereum-waffle": "3.4.0",
-    "ethers": "5.4.1",
+    "ethers": "6.13.5",
     "hardhat": "^2.21.0",
     "hardhat-preprocessor": "0.1.4",
     "husky": "6.0.0",
@@ -99,15 +99,15 @@
     "standard-version": "9.3.0",
     "ts-node": "10.0.0",
     "tsconfig-paths": "^3.9.0",
-    "typechain": "5.1.1",
+    "typechain": "8.3.2",
     "typescript": "4.9.5"
   },
   "peerDependencies": {
-    "@ethersproject/abi": "^5",
-    "@ethersproject/abstract-provider": "^5",
-    "@ethersproject/abstract-signer": "^5",
+    "@ethersproject/abi": "^5 || ^6",
+    "@ethersproject/abstract-provider": "^5 || ^6",
+    "@ethersproject/abstract-signer": "^5 || ^6",
     "@nomiclabs/hardhat-ethers": "^2",
-    "ethers": "^5",
+    "ethers": "^5 || ^6",
     "hardhat": "^2.21.0"
   }
 }

@robhyrk
Copy link
Author

robhyrk commented Feb 10, 2025

@0xteddybear do you have a branch open where you started these changes? I'd be open to checking it out and attempting to continue chipping away at this.

I'm new to solidity but I came across this package in a course I was doing. would be great to have it updated.

@0xteddybear
Copy link

do you have a branch open where you started these changes? I'd be open to checking it out and attempting to continue chipping away at this.

All the changes I tried out so far are contained in the patch above (well, sans the yarn.lock, but there's no use adding it to the patch I share)

I'm new to solidity but I came across this package in a course I was doing. would be great to have it updated

If you are starting out I highly recommend to try out foundry and our re-implementation of this: https://github.com/defi-wonderland/smock-foundry .

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

No branches or pull requests

3 participants