10 请教import @uniswap/v2-core/contracts/interfaces/IPancakePair.sol编译报错问题

package.json中有@uniswap/v2-core依赖,我已执行npm install命令:

"dependencies": {
    "@uniswap/lib": "1.1.1",
    "@uniswap/v2-core": "^1.0.1",
    "truffle-hdwallet-provider": "^1.0.17",
    "truffle-plugin-verify": "^0.4.0"
  }

truffle编译报错信息如下:

Error: Could not find @uniswap/v2-core/contracts/interfaces/IPancakePair.sol from any sources; imported from /Users/wangwei/Workspace/blockchain/ETH/pancake-swap-periphery/contracts/libraries/PancakeLibrary.sol
    at Resolver.<anonymous> (/usr/local/lib/node_modules/truffle/build/webpack:/packages/resolver/dist/lib/resolver.js:62:1)
    at Generator.next (<anonymous>)
    at fulfilled (/usr/local/lib/node_modules/truffle/build/webpack:/packages/resolver/dist/lib/resolver.js:5:42)
Truffle v5.1.60 (core: 5.1.60)
Node v14.15.1

合约源码:

pragma solidity >=0.5.0;

import '@uniswap/v2-core/contracts/interfaces/IPancakePair.sol';

import "./SafeMath.sol";

library PancakeLibrary {
    using SafeMath for uint;

    // returns sorted token addresses, used to handle return values from pairs sorted in this order
    function sortTokens(address tokenA, address tokenB) internal pure returns (address token0, address token1) {
        require(tokenA != tokenB, 'PancakeLibrary: IDENTICAL_ADDRESSES');
        (token0, token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA);
        require(token0 != address(0), 'PancakeLibrary: ZERO_ADDRESS');
    }
请先 登录 后评论

最佳答案 2021-05-19 18:27

这里那里来的代码。

@uniswap 的包里怎么会有 Pancake 的代码呢? ?

请先 登录 后评论

其它 3 个回答

chobyn
请先 登录 后评论
chobyn
请先 登录 后评论
lmx?
请先 登录 后评论
  • 3 关注
  • 0 收藏,5101 浏览
  • wangwei123 提出于 2021-05-19 18:04