Brownie 导入文件包含带有“@...”的导入内容

发布于 2025-01-15 03:16:59 字数 1805 浏览 0 评论 0原文

我有这个合同:

pragma solidity >=0.8.0;
import "Uniswap/[email protected]/contracts/interfaces/IUniswapV3Pool.sol";
import "Uniswap/[email protected]/contracts/interfaces/ISwapRouter.sol";

contract Test {

}

并且这个 Brownie-config.yaml:

dependencies:
  - Uniswap/[email protected]
  - Uniswap/[email protected]

使用 browniecompile 抛出以下内容:

ParserError: Source "@uniswap/v3-core/contracts/interfaces/callback/IUniswapV3SwapCallback.sol" not found: File outside of allowed directories.
 --> C:/Users/username/.brownie/packages/Uniswap/[email protected]/contracts/interfaces/ISwapRouter.sol:5:1:
  |
5 | import '@uniswap/v3-core/contracts/interfaces/callback/IUniswapV3SwapCallback.sol';
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

对我来说,此导入无法解析是有道理的,但是无论如何都可以在不修改的情况下修复此问题Uniswap 源代码?

编辑:澄清一下,这就是 ISwapRouter.sol 的开头:

// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.7.5;
pragma abicoder v2;

import '@uniswap/v3-core/contracts/interfaces/callback/IUniswapV3SwapCallback.sol';

导入“@uniswap/...”是导致问题的原因

I have this contract:

pragma solidity >=0.8.0;
import "Uniswap/[email protected]/contracts/interfaces/IUniswapV3Pool.sol";
import "Uniswap/[email protected]/contracts/interfaces/ISwapRouter.sol";

contract Test {

}

and this brownie-config.yaml:

dependencies:
  - Uniswap/[email protected]
  - Uniswap/[email protected]

using brownie compile throws the following:

ParserError: Source "@uniswap/v3-core/contracts/interfaces/callback/IUniswapV3SwapCallback.sol" not found: File outside of allowed directories.
 --> C:/Users/username/.brownie/packages/Uniswap/[email protected]/contracts/interfaces/ISwapRouter.sol:5:1:
  |
5 | import '@uniswap/v3-core/contracts/interfaces/callback/IUniswapV3SwapCallback.sol';
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Makes sense to me that this import can't be resolved, but is there anyway to fix this without modifying the Uniswap source code?

Edit: to clarify, this is what the beginning of ISwapRouter.sol looks like:

// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.7.5;
pragma abicoder v2;

import '@uniswap/v3-core/contracts/interfaces/callback/IUniswapV3SwapCallback.sol';

the import of '@uniswap/..." is what is causing the problem

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

生活了然无味 2025-01-22 03:16:59

在 Brownie-config.yaml 文件中

添加重新映射

compiler:
  solc:
    remappings: 
      # put the correct version
      - "@uniswap/lib=uniswap/[email protected]"
      - "@uniswap/v2-core=uniswap/[email protected]"
      

in brownie-config.yaml file

add remappings

compiler:
  solc:
    remappings: 
      # put the correct version
      - "@uniswap/lib=uniswap/[email protected]"
      - "@uniswap/v2-core=uniswap/[email protected]"
      
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文