I’m trying to compile a smart contract TestMinter.sol that inherits from ERC20PresetMinterPauser.sol using the @openzeppelin/contracts library and Truffle. TestMinter.sol seems to import the ERC20PresetMinterPauser.sol correctly using
import "node_modules/@openzeppelin/contracts/presets/ERC20PresetMinterPauser.sol";
But then when ERC20PresetMinterPauser.sol tries to import I get a File import callback not supported
error:
$ truffle compile
Compiling your contracts...
===========================
> Compiling ./contracts/Migrations.sol
> Compiling ./contracts/TestMinter.sol
> Compiling ./node_modules/@openzeppelin/contracts/GSN/Context.sol
> Compiling ./node_modules/@openzeppelin/contracts/access/AccessControl.sol
> Compiling ./node_modules/@openzeppelin/contracts/math/SafeMath.sol
> Compiling ./node_modules/@openzeppelin/contracts/token/ERC20/ERC20.sol
> Compiling ./node_modules/@openzeppelin/contracts/token/ERC20/ERC20Burnable.sol
> Compiling ./node_modules/@openzeppelin/contracts/token/ERC20/ERC20Pausable.sol
> Compiling ./node_modules/@openzeppelin/contracts/token/ERC20/IERC20.sol
> Compiling ./node_modules/@openzeppelin/contracts/utils/Address.sol
> Compiling ./node_modules/@openzeppelin/contracts/utils/EnumerableSet.sol
> Compiling ./node_modules/@openzeppelin/contracts/utils/Pausable.sol
> Compiling node_modules/@openzeppelin/contracts/presets/ERC20PresetMinterPauser.sol
CompileError: node_modules/@openzeppelin/contracts/presets/ERC20PresetMinterPauser.sol:5:1: ParserError: Source "node_modules/@openzeppelin/contracts/access/AccessControl.sol" not found: File import callback not supported
import "../access/AccessControl.sol";
^-----------------------------------^
,node_modules/@openzeppelin/contracts/presets/ERC20PresetMinterPauser.sol:6:1: ParserError: Source "node_modules/@openzeppelin/contracts/GSN/Context.sol" not found: File import callback not supported
import "../GSN/Context.sol";
^--------------------------^
,node_modules/@openzeppelin/contracts/presets/ERC20PresetMinterPauser.sol:7:1: ParserError: Source "node_modules/@openzeppelin/contracts/token/ERC20/ERC20.sol" not found: File import callback not supported
import "../token/ERC20/ERC20.sol";
^--------------------------------^
,node_modules/@openzeppelin/contracts/presets/ERC20PresetMinterPauser.sol:8:1: ParserError: Source "node_modules/@openzeppelin/contracts/token/ERC20/ERC20Burnable.sol" not found: File import callback not supported
import "../token/ERC20/ERC20Burnable.sol";
^----------------------------------------^
,node_modules/@openzeppelin/contracts/presets/ERC20PresetMinterPauser.sol:9:1: ParserError: Source "node_modules/@openzeppelin/contracts/token/ERC20/ERC20Pausable.sol" not found: File import callback not supported
import "../token/ERC20/ERC20Pausable.sol";
^----------------------------------------^
Compilation failed. See above.
at run (/home/contooter/.npm-global/lib/node_modules/truffle/build/webpack:/packages/compile-solidity/run.js:52:1)
at Object.sourcesWithDependencies (/home/contooter/.npm-global/lib/node_modules/truffle/build/webpack:/packages/compile-solidity/index.js:107:56)
at necessary (/home/contooter/.npm-global/lib/node_modules/truffle/build/webpack:/packages/compile-solidity/index.js:69:1)
at /home/contooter/.npm-global/lib/node_modules/truffle/build/webpack:/packages/workflow-compile/index.js:33:1
at async Promise.all (index 0)
at compile (/home/contooter/.npm-global/lib/node_modules/truffle/build/webpack:/packages/workflow-compile/index.js:23:1)
at Object.compile (/home/contooter/.npm-global/lib/node_modules/truffle/build/webpack:/packages/workflow-compile/index.js:66:45)
Truffle v5.1.57 (core: 5.1.57)
Node v14.15.1
Environment
Truffle v5.1.57 (solc 0.6.2)
Node v14.15.1
@openzeppelin/contracts 3.3.0
Linux Mint 20
I could probably do a workaround and change all the smart contracts import paths to full paths but I rather not mess around with the preconfigured contracts from OZ because of security reasons.