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');
}