hardhat
hardhat copied to clipboard
Support importing contracts through the current workspace name
If you have a monorepo, and you have two workspaces A and B, you can import contracts from A in B doing:
import "A/contracts/SomeContract.sol";
But you can't import them from the same workspace:
import "B/contracts/SomeOtherContract.sol";
This never worked for monorepos, but in v2.12.3 we started detecting this situation, and throwing a better error message.
The problem is that this forbids importing hardhat/console.sol if your package is named hardhat (which will happen if you do mkdir hardhat && cd hardhat && npm init -y); see issues #3623 and #3624.
We should just support this in monorepos and stop throwing the error.
Hi! Thanks for responding to me on #3624
Unfortunately the reason you stated is not correct - The name in my package.json is not "solmate" - it's "@uniswap/universal-router"
Interestingly we have multiple git submodules in the root of the folder: solmate and permit2. Since version 2.12.3 hardhat can no longer find solmate but it can still find permit2.
Sorry @hensha256, I read your issue quickly and assumed it was also about hardhat/console.sol; I realize now that it isn't.
I think we might have a bug in an (intended) improvement we added in 2.12.3. I'll look into it as soon as I can.
Error HH412: Invalid import hardhat/console.sol from contracts/Token.sol. Trying to import file using the own package's name.
i still dont understand how to solve this issue
@uchihaada see this comment for that specific issue
PR created at https://github.com/NomicFoundation/hardhat/pull/4039.
hey @fvictorio ! Just wondering if theres any update here? Still facing this issue 😢
@hensha256 Not yet, but we'll try to prioritize it as soon as we have some bandwidth.
Error HH412: Invalid import hardhat/console.sol from contracts/Token.sol. Trying to import file using the own package's name.
I tried to start my boilerplate for hardhat from the scratch.
I also had a same issue on 2.22.8 version. You can check my issue here #5603 Plz fix it soon~ 🙏