foundry-rs / hardhat

Foundry-Hardhat plugins: Use Foundry for Hardhat projects
Other
93 stars 18 forks source link

Unable to resolve import: "INSERT_CONTRACT" with remappings when using NPM workspaces #58

Open kamescg opened 2 years ago

kamescg commented 2 years ago

The situation

I have Turborepo + pnpm project setup; a workspaces monorepo with a symlink dependency graph.

When running hardhat compile with the foundry-rs/hardhat-* plugins installed I get the following mapping errors.

[⠊] Compiling...
[⠒] Unable to resolve import: "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol" with remappings:
        contracts/=/Users/kames/workspace/kames/code/turbo-eth/contracts/
[⠢] Unable to resolve import: "@openzeppelin/contracts/access/Ownable.sol" with remappings:
        contracts/=/Users/kames/workspace/kames/code/turbo-eth/contracts/
[⠆] Unable to resolve import: "@openzeppelin/contracts/token/ERC20/IERC20.sol" with remappings:
        contracts/=/Users/kames/workspace/kames/code/turbo-eth/contracts/
...
...
...
[⠊] Unable to resolve import: "../../node_modules/zeppelin-solidity/contracts//math/SafeMath.sol" with remappings:
        contracts/=/Users/kames/workspace/kames/code/turbo-eth/contracts/

This is obviously a problem with my monorepo build system, but just wanted to flag this issue.

Maybe someone has an idea for a good work-around to get foundry-rs to work nicely in an NPM workspaces build setup?

tynes commented 2 years ago

What do your remappings, filesystem and deps look like? I'm not sure if this is a problem with the hardhat plugin, foundry/ethers-rs or your config. I was able to use foundry within a monorepo to import other packages in the Optimism monorepo, although we have refactored it to no longer need to import contracts from other packages.

kamescg commented 2 years ago

Let me double check all the configurations and I will get back to you. I ran the same smart contract repo outside of the monorepo and it compiled without any of the remapping warnings, so I assume I everything was fine, but I also may have missed something else and I just want to double check before I look foolish ;)