Erc-721

布朗尼編譯命令允許目錄之外的文件

  • March 22, 2022

嘗試從我的契約文件中的 openzeppelin 和 chainlink 導入文件,如下所示:

import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@chainlink/contracts/src/v0.6/VRFConsumerBase.sol";

我有一個 brownie-config.yaml 文件,如下所示:

dependencies:
 - OpenZeppelin/openzeppelin-contracts@3.4.0
 - smartcontractkit/chainlink-brownie-contracts@1.0.2 
 compiler:
   solc:
     remappings: 
       - '@openzeppelin=OpenZepplin/openzeppelin-contracts@3.4.0'
       - '@chainlink=smartcontractkit/chainlink-brownie-contracts@1.0.2'

當我執行“brownie compile”命令時,我得到:

CompilerError: solc returned the following errors:

contracts/AdvancedCollectible.sol:4:1: ParserError: Source "https:\github.com/OpenZeppelin/openzeppelin-contracts/blob/release-v3.4/contracts/token/ERC721/ERC721.sol" not found: File outside of allowed directories.
import "https:\\github.com/OpenZeppelin/openzeppelin-contracts/blob/release-v3.4/contracts/token/ERC721/ERC721.sol";
^------------------------------------------------------------------------------------------------------------------^

contracts/AdvancedCollectible.sol:6:1: ParserError: Source "https:\github.com/smartcontractkit/chainlink-brownie-contracts/blob/release-v1.0.2/contracts/src/v0.6/VRFConsumerBase.sol" not found: File outside of allowed directories.
import "https:\\github.com/smartcontractkit/chainlink-brownie-contracts/blob/release-v1.0.2/contracts/src/v0.6/VRFConsumerBase.sol";
^----------------------------------------------------------------------------------------------------------------------------------^

我也嘗試像下面這樣導入,但沒有運氣:

import "https:\\github.com/OpenZeppelin/openzeppelin-contracts/blob/release-v3.4/contracts/token/ERC721/ERC721.sol";
import "https:\\github.com/smartcontractkit/chainlink-brownie-contracts/blob/release-v1.0.2/contracts/src/v0.6/VRFConsumerBase.sol";

所以基本上我不小心在項目文件夾之外創建了 brownie-yaml.config 文件。

some-folder
| -project-folder
|  | -src
|  | -contracts
|  | -...
brownie-config.yaml

一旦我將.yaml文件移動到項目文件夾中,一切正常

對我來說,在重新映射之後我不小心沒有留下空間-。我有:

compiler:
 solc:
   remappings:
     -'@aave=aave/protocol-v2@1.0.1'
...

我需要:

compiler:
 solc:
   remappings:
     # notice the space
     - '@aave=aave/protocol-v2@1.0.1'
...

引用自:https://ethereum.stackexchange.com/questions/109758