OpenZeppelin Contracts error during compilation
I'm getting the following error when running 'npm run build':
Error: None of the sub-resolvers resolved "../../GSN/Context.sol" location.
waffle.json:
{
"compilerType": "solcjs",
"compilerVersion": "0.6.2",
"sourceDirectory": "./src",
"outputDirectory": "./build",
}
package.json (extract):
"scripts": {
"start": "node index",
"build": "waffle"
},
"dependencies": {
"dotenv": "^8.2.0",
"ethers": "^5.0.28"
},
"devDependencies": {
"@openzeppelin/contracts": "^3.4.0",
"ethereum-waffle": "^3.2.2"
}
contract:
pragma solidity ^0.6.0;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
contract BasicToken is ERC20 {
constructor(uint256 initialBalance) ERC20("Basic", "BSC") public {
_mint(msg.sender, initialBalance);
_setupDecimals(0);
}
}
I have encountered this too, in a project with both Chainlink and OpenZeppelin imports, only the OpenZeppelin ones cause the issue.
Minimal example with yarn add completed for both repositories:
Contract
pragma solidity ^0.6.6;
import "@openzeppelin/contracts/access/Ownable.sol";
contract AnyRateOracle is Ownable { constructor() public {} }
Terminal Output
$ yarn waffle
yarn run v1.22.10
$ /Users/----/Documents/Projects/Programming/-----/oss/bugs/waffle-imports/node_modules/.bin/waffle
Error: None of the sub-resolvers resolved "@openzeppelin/contracts/access/Ownable.sol" location.
at resolverError (/Users/-----/Documents/Projects/Programming/----/oss/bugs/waffle-imports/node_modules/@resolver-engine/core/build/resolverengine.js:75:32)
at ResolverEngine.<anonymous> (/Users/-----/Documents/Projects/Programming/-----/oss/bugs/waffle-imports/node_modules/@resolver-engine/core/build/resolverengine.js:52:23)
at Generator.next (<anonymous>)
at fulfilled (/Users/-----/Documents/Projects/Programming/----/oss/bugs/waffle-imports/node_modules/@resolver-engine/core/build/resolverengine.js:4:58)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
note: paths with '-----' are my own redactions
waffle.json
{
"compilerType": "solcjs",
"compilerVersion": "0.6.6",
"sourceDirectory": "./contracts",
"outputDirectory": "./build"
}
About my waffle version
"@ethereum-waffle/compiler@^3.3.0":
version "3.3.1"
resolved "https://registry.yarnpkg.com/@ethereum-waffle/compiler/-/compiler-3.3.1.tgz#946128fd565aa4347075fd716dbd0f3f38189280"
integrity sha512-X/TeQugt94AQwXEdCjIQxcXYGawNulVBYEBE7nloj4wE/RBxNolXwjoVNjcS4kuiMMbKkdO0JkL5sn6ixx8bDg==
dependencies:
"@resolver-engine/imports" "^0.3.3"
"@resolver-engine/imports-fs" "^0.3.3"
...
I have not been able to reproduce the problem from @severalpens, and with problem from @slhodak I have something else:
Error: None of the sub-parsers resolved "src/contracts/AnyRateOracle.sol" into data. Please confirm your configuration.
Which goes away once I add any content to the smart contract except the empty constructor. So it seems like I have not been able to reproduce the error with resolving the OpenZeppeling contracts. So I'm going to close it now as non-reproducible, but feel free to reopen if the issue still persists for you, and you have another piece of code/configuration I can try.