I'm trying to compile a smart contract using the apeworx framework in WSL on Windows. My contract has these dependencies:
import "@openzeppelin/contracts/access/Ownable.sol";
import "@uniswap/v3-periphery/contracts/interfaces/ISwapRouter.sol";
In my ape-config.yaml file I have the following:
name: TestContract
dependencies:
- name: OpenZeppelin
github: OpenZeppelin/openzeppelin-contracts
version: 4.4.2
- name: Uniswap
github: Uniswap/v3-periphery
ref: v1.2.0
I can see during ape compile
that both repos were found and I have two directories in .ape/packages/projects
:
OpenZeppelin_openzeppelin-contracts
Uniswap_v3-periphery
However ape compile
fails with the following error:
INFO: Compiling using Solidity compiler '0.8.28+commit.7893614a'.
Input:
contracts/.cache/openzeppelin/4.4.2/contracts/access/Ownable.sol
contracts/.cache/openzeppelin/4.4.2/contracts/security/Pausable.sol
contracts/.cache/openzeppelin/4.4.2/contracts/security/ReentrancyGuard.sol
contracts/.cache/openzeppelin/4.4.2/contracts/token/ERC20/IERC20.sol
contracts/.cache/openzeppelin/4.4.2/contracts/utils/Context.sol
contracts/FlexiblePayments.sol
ERROR: (SolcCompileError) ParserError: Source "contracts/.cache/uniswap/v1.2.0/v3-periphery/contracts/interfaces/ISwapRouter.sol" not found: File not found. Searched the following locations: "/tmp/tmp3yk74hcb/TestContract".
--> contracts/FlexiblePayments.sol:8:1:
|
8 | import "@uniswap/v3-periphery/contracts/interfaces/ISwapRouter.sol";
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
I can't seem to get past this. I've verified that .ape/packages/projects/Uniswap_v3-periphery/v1_2_0/contracts/interfaces/ISwapRouter.sol
exists it just cannot be found by the compiler.
The worst place to ask a question related to blockchain. Received so much hate here. Anyway, it looks like you need to define the remappings.
name: TestContract
dependencies:
- name: OpenZeppelin
github: OpenZeppelin/openzeppelin-contracts
version: 4.4.2
- name: Uniswap
github: Uniswap/v3-periphery
ref: 1.2.0
solidity:
import_remapping:
- "@uniswap/v3-periphery/contracts=Uniswap-periphery/1.2.0"
- "@openzeppelin/contracts=OpenZeppelin/4.4.2"
Reference
Also the oz and periphery versions are quiet outdated unless you have specific reason to use those versions always use the latest releases.