smartcontractkit / chainlink-brownie-contracts

A repository for automatically using the latest chainlink repo from the core chainlink repo.
327 stars 69 forks source link

Unable to compile v0.2.2 #5

Closed hexcowboy closed 3 years ago

hexcowboy commented 3 years ago

Getting a NamespaceCollision error with the latest release:

WARNING: Unable to compile smartcontractkit/chainlink-brownie-contracts@0.2.2 due to a NamespaceCollision - you may still be able to import sources from the package, but will be unable to load the package directly.

New compatible solc version available: 0.8.6
Compiling contracts...
  Solc version: 0.7.6
  Optimizer: Enabled  Runs: 200
  EVM Version: Istanbul
CompilerError: solc returned the following errors:

contracts/Oracle.sol:4:1: ParserError: Source "~/.brownie/packages/smartcontractkit/chainlink-brownie-contracts@0.2.1/contracts/src/v0.7/Operator.sol" not found: File not found.
import "@chainlink/contracts/src/v0.7/Operator.sol";
^--------------------------------------------------^
➜ brownie --version
Brownie v1.16.4 - Python development framework for Ethereum
H0ussam commented 3 years ago

I have the same issue as yours!

PatrickAlphaC commented 3 years ago

Could you delete the build folder and try again? It looks like your trying to work with 2 different versions of the folder.

omnifient commented 3 years ago

Got the same warning as OP (but no error). Deleting the build folder and re-compiling was successful.

But @PatrickAlphaC can you give more details into what's causing this issue?

PatrickAlphaC commented 3 years ago

@omnifient, basically, you have 2 versions of the same package downloaded in your dependencies, hence the name collision. So deleting the build folder removes the downloaded incorrect dependencies.

I think this would be an improvement to put into brownie.

PatrickAlphaC commented 3 years ago

Closing for now, feel free to follow up.

woosal1337 commented 2 years ago

I am having the same exact problem even after deleting the build folder. It does not really look exactly the same as yours, however, very similar. The error is as following:

woosal@woosal:/media/woosal/1337/GitHub/blockchain/codes/brownie_fund_me$ brownie compile
Brownie v1.17.1 - Python development framework for Ethereum

Compiling contracts...
  Solc version: 0.6.12
  Optimizer: Enabled  Runs: 200
  EVM Version: Istanbul
CompilerError: solc returned the following errors:

contracts/FundMe.sol:5:1: ParserError: Source "@chainlink/contracts/src/v0.6/interfaces/AggregatorV3Interface.sol" not found: File outside of allowed directories.
import "@chainlink/contracts/src/v0.6/interfaces/AggregatorV3Interface.sol";
^--------------------------------------------------------------------------^

contracts/FundMe.sol:6:1: ParserError: Source "@chainlink/contracts/src/v0.6/vendor/SafeMathChainlink.sol" not found: File outside of allowed directories.
import "@chainlink/contracts/src/v0.6/vendor/SafeMathChainlink.sol";
^------------------------------------------------------------------^

My yaml file is as following:

dotenv: .env
dependencies:
  - smartcontractkit/chainlink-brownie-contracts@1.1.1
compiler:
  solc:
    ramappings:
      - '@chainlink=smartcontractkit/chainlink-brownie-contracts@1.1.1'
PatrickAlphaC commented 2 years ago

Odd.

Whats in your ~/.brownie/packages/chainlink folder?

fletheno1 commented 2 years ago

hi, I've porbably found the sollution to this porblem on Win10 VScode :

hopefully it helps to follow this great tutotial of @PatrickAlphaC

PatrickAlphaC commented 2 years ago

Awesome work :)

And yes, hopefully this will help others!

yataishiba commented 2 years ago

I encountered the same problem and followed your instruction. It compiled but I received another error.

  File "brownie/_cli/__main__.py", line 64, in main
    importlib.import_module(f"brownie._cli.{cmd}").main()
  File "brownie/_cli/compile.py", line 50, in main
    proj = project.load()
  File "brownie/project/main.py", line 751, in load
    return Project(name, project_path)
  File "brownie/project/main.py", line 183, in __init__
    self.load()
  File "brownie/project/main.py", line 238, in load
    self._compile(changed, self._compiler_config, False)
  File "brownie/project/main.py", line 95, in _compile
    build_json = compiler.compile_and_format(
  File "brownie/project/compiler/__init__.py", line 132, in compile_and_format
    input_json = generate_input_json(
  File "brownie/project/compiler/__init__.py", line 190, in generate_input_json
    input_json["settings"]["remappings"] = _get_solc_remappings(remappings)
  File "brownie/project/compiler/__init__.py", line 208, in _get_solc_remappings
    remap_dict = dict(i.split("=") for i in remappings)
ValueError: dictionary update sequence element #0 has length 1; 2 is required

can anyone help me with this error? thanks

PatrickAlphaC commented 2 years ago

Please post your config

TheoremaLC commented 2 years ago

Hi, i have the same issue as everyone here, I just took a look at the chainlink/contracts/src/v0.8/interfaces path and found the AggregatorV3Interface, I just dont understand why the compiler keeps returning "source not found: file outside of allowed directries."

JLyncee350 commented 2 years ago

I switched to v0.6 and that worked for me. So try chainlink/contracts/src/v0.6/interfaces. Seems any version past 6 won't compile.

baris-celebi commented 2 years ago

hi, I've porbably found the sollution to this porblem on Win10 VScode :

* 1 create **.vscode** folder and **setting.json** file ... [https://supunkavinda.blog/vscode-editing-settings-json#workspace](url)
  ![image](https://user-images.githubusercontent.com/15129218/148653324-bbe5c1b2-e9f4-4937-bba6-8211ebc97aaf.png)

* 2 in setting just set up correct path to your smartcontractkit importet by brownie due to compile:

* {
  "solidity.remappings": [
  "@chainlink/=**C:\Users\XPS 15\**.brownie\packages\smartcontractkit\chainlink-brownie-contracts@1.1.1"
  ]
  } .... [https://stackoverflow.com/questions/69306209/imports-for-chainlink-and-openzeppelinn-are-broken](url)
  ![image](https://user-images.githubusercontent.com/15129218/148653345-2509ed78-c27d-4589-9e46-e81ffa22dc2f.png)

hopefully it helps to follow this great tutotial of @PatrickAlphaC

thanks mate. it worked for me, now it doesnt show error when i compile. but nothing came to build folder. its still empty.

resim

jamellknows commented 2 years ago

check your brownie-config.yaml file. If not make one.