Adding an interface contract breaks compilation for Solidity
See original GitHub issueEnvironment information
brownie
Version: 1.11.0ganache-cli
Version: n/asolc
Version: n/a- Python Version: 3.7
- OS: osx
What was wrong?
brownie init
ln -s <compound-protocol-clone/contracts> contracts/
This sets up a basic repository that uses compound contracts from an external folder and can be compiled with
brownie compile
However, when I add an interface either by copying ComptrollerInterface.sol
to an interfaces
folder or by symlinking ComptrollerInterface.sol
within interfaces
, compilation fails with these errors:
Compiling contracts...
Solc version: 0.5.17
Optimizer: Enabled Runs: 200
EVM Version: Istanbul
CompilerError: solc returned the following errors:
contracts/Comptroller.sol:3:1: ParserError: Source "contracts/CToken.sol" not found: File outside of allowed directories.
import "./CToken.sol";
^--------------------^
contracts/Comptroller.sol:4:1: ParserError: Source "contracts/ErrorReporter.sol" not found: File outside of allowed directories.
import "./ErrorReporter.sol";
... continues - 1 for each contract
How can it be fixed?
Feels like adding the interface may change the working solc
directory?
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Solidity Tutorial: all about interfaces | by Jean Cvllr - Medium
An interface contract in Solidity will lead to two main pieces of information: ... Otherwise, the Solidity compiler will throw an error. Both...
Read more >Contracts — Solidity 0.8.17 documentation
When a contract inherits from other contracts, only a single contract is created on the blockchain, and the code from all the base...
Read more >Solidity - Basics of Interface - GeeksforGeeks
Interfaces are the same as abstract contracts created by using an interface keyword, also known as a pure abstract contract.
Read more >Learn Solidity – A Handbook for Smart Contract Development
A constructor is a special type of function. In Solidity, it is optional and is executed once only on contract creation. In the...
Read more >Solidity Cheatsheet and Best practices - Manoj
Interface · Cannot have any functions implemented. · Cannot inherit other contracts or interfaces. · Cannot define constructor. · Cannot define variables. ·...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think I was able to fix it by recursively copying
node_modules/*
tointerfaces/
but now i have a new error
NamespaceCollision: Multiple contracts or interfaces with the same name
update: I was able to use this to fix and now my project is compiling https://github.com/iearn-finance/vaults/blob/master/brownie-config.yaml#L9
`/brownie$ brownie compile Brownie v1.11.0 - Python development framework for Ethereum
Compiling contracts… Solc version: 0.7.1 Optimizer: Enabled Runs: 200 EVM Version: Istanbul CompilerError: solc returned the following errors:
contracts/testtoken.sol:5:1: ParserError: Source “@openzeppelin/contracts/token/ERC20/ERC20Pausable.sol” not found: File outside of allowed directories. import “@openzeppelin/contracts/token/ERC20/ERC20Pausable.sol”; ^-------------------------------------------------------------^
contracts/testtoken.sol:6:1: ParserError: Source “@openzeppelin/contracts/access/Ownable.sol” not found: File outside of allowed directories. import “@openzeppelin/contracts/access/Ownable.sol”; ^--------------------------------------------------^ `