solidity-flattener icon indicating copy to clipboard operation
solidity-flattener copied to clipboard

contracts under openzeppelin are not included

Open KimiWu123 opened this issue 4 years ago • 8 comments

used poa-solidity-flattener to flatten my contract to upload to etherscan. xxx_flat.sol was generated successfully but we have some @openzeppelin dependencies, like IERC20, Context... were not be included in the final xxx_falt.sol. Not sure what happened. Here are some messages saying those files are not found in the beginning, but found later. But they are not included in the output file.

{"name":"solidity-flattener","hostname":"kimiwude-mbp.lan","pid":96101,"level":40,"msg":"!!! @openzeppelin/contracts-ethereum-package/contracts/math/SignedSafeMath.sol SOURCE FILE WAS NOT FOUND. I'M TRYING TO FIND IT RECURSIVELY !!!","time":"2020-10-26T07:47:54.428Z","v":0}
{"name":"solidity-flattener","hostname":"kimiwude-mbp.lan","pid":96101,"level":30,"msg":"@openzeppelin/contracts-ethereum-package/contracts/math/SignedSafeMath.sol SOURCE FILE WAS FOUND","time":"2020-10-26T07:47:54.439Z","v":0}
...
{"name":"solidity-flattener","hostname":"kimiwude-mbp.lan","pid":95092,"level":40,"msg":"!!! @openzeppelin/contracts/token/ERC20/IERC20.sol SOURCE FILE WAS NOT FOUND. I'M TRYING TO FIND IT RECURSIVELY !!!","time":"2020-10-26T07:32:36.865Z","v":0}
{"name":"solidity-flattener","hostname":"kimiwude-mbp.lan","pid":95092,"level":30,"msg":"@openzeppelin/contracts/token/ERC20/IERC20.sol SOURCE FILE WAS FOUND","time":"2020-10-26T07:32:36.875Z","v":0}

poa-solidity-flattener version: 3.0.6 build environment: buidler

KimiWu123 avatar Oct 26 '20 07:10 KimiWu123

I @KimiWu123 I have the same issue. Have you already found a solution?

arnoudcommandeur avatar Nov 17 '20 22:11 arnoudcommandeur

@arnoudcommandeur , no idea how to fix it, we use truffle-flattener now.

KimiWu123 avatar Nov 18 '20 01:11 KimiWu123

Ok, thanks. @KimiWu123

arnoudcommandeur avatar Nov 18 '20 11:11 arnoudcommandeur

Hi @KimiWu123, I had some issues using truffle-flattener because my directoryname contained soms special characters. Now I have changed the name to c:\Temp and the truffle-flattener is working. Thanks!

arnoudcommandeur avatar Nov 25 '20 08:11 arnoudcommandeur

I tried truffle-flattener but it failed.

For this issue, copy the openzepplin's "contracts" directory to ./node_modules/.bin/poa-solidity-flattener then it should work. your contract should look use import with relative path like this: import "./contracts/token/ERC20/presets/ERC20PresetMinterPauser.sol"; It works in this https://github.com/ngduc/flatten-sol

ngduc avatar Jul 15 '21 21:07 ngduc

sol-merger works fine, contrary to this script.

npm install sol-merger -g
sol-merger ./contracts/my.sol ./merged

ozh avatar Aug 20 '21 14:08 ozh

Thanks @ozh. You solved my problem!

kilogold avatar Sep 16 '21 18:09 kilogold

Haha, thanks @ozh! Now, it's too simple.

hapetherw avatar Feb 03 '22 10:02 hapetherw