question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Adding an interface contract breaks compilation for Solidity

See original GitHub issue

Environment information

  • brownie Version: 1.11.0
  • ganache-cli Version: n/a
  • solc 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:open
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
sabotagebeatscommented, Sep 3, 2020

I think I was able to fix it by recursively copying node_modules/* to interfaces/

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

0reactions
sabotagebeatscommented, Sep 3, 2020

`/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”; ^--------------------------------------------------^ `

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found