BlockCatIO / solidity-flattener

A python utility to flatten Solidity code with imports into a single file.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to use this with truffle?

nmiculinic opened this issue · comments

I'm having issues using this with truffle framework -- specifically I'm using zeppelin modules in node_modules and the best I got is:

solidity_flattener --solc-paths "=$(pwd)/node_modules/ " contracts/Shitcoin.sol

with error:

contracts/Shitcoin.sol:3:1: Error: Source "/home/lpp/Desktop/shitcoin/node_modules/ zeppelin-solidity/contracts/token/MintableToken.sol" not found: Unknown exception in read callback.
import 'zeppelin-solidity/contracts/token/MintableToken.sol';
^-----------------------------------------------------------^
Traceback (most recent call last):
  File "/usr/bin/solidity_flattener", line 99, in <module>
    main()
  File "/usr/bin/solidity_flattener", line 95, in main
    solc_proc.check_returncode()
  File "/usr/lib/python3.6/subprocess.py", line 369, in check_returncode
    self.stderr)
subprocess.CalledProcessError: Command '['solc', '=/home/lpp/Desktop/shitcoin/node_modules/ ', '--ast', 'contracts/Shitcoin.sol']' returned non-zero exit status 1.

or

 shitcoin (master) ✔ solidity_flattener --solc-paths "=node_modules/" contracts/Shitcoin.sol 
contracts/Shitcoin.sol:3:1: Error: Source "node_modules/zeppelin-solidity/contracts/token/MintableToken.sol" not found: File outside of allowed directories.
import 'zeppelin-solidity/contracts/token/MintableToken.sol';
^-----------------------------------------------------------^
Traceback (most recent call last):
  File "/usr/bin/solidity_flattener", line 99, in <module>
    main()
  File "/usr/bin/solidity_flattener", line 95, in main
    solc_proc.check_returncode()
  File "/usr/lib/python3.6/subprocess.py", line 369, in check_returncode
    self.stderr)
subprocess.CalledProcessError: Command '['solc', '=node_modules/', '--ast', 'contracts/Shitcoin.sol']' returned non-zero exit status 1.

contracts/Shitcoin.sol:3:1: Error: Source "/home/lpp/Desktop/shitcoin/node_modules/ zeppelin-solidity/contracts/token/MintableToken.sol" not found: Unknown exception in read callback.
Means that the dir is incorrect

contracts/Shitcoin.sol:3:1: Error: Source "node_modules/zeppelin-solidity/contracts/token/MintableToken.sol" not found: File outside of allowed directories.
import 'zeppelin-solidity/contracts/token/MintableToken.sol';
^-----------------------------------------------------------^
Traceback (most recent call last):
  File "/usr/bin/solidity_flattener", line 99, in <module>
    main()
  File "/usr/bin/solidity_flattener", line 95, in main
    solc_proc.check_returncode()
  File "/usr/lib/python3.6/subprocess.py", line 369, in check_returncode
    self.stderr)
subprocess.CalledProcessError: Command '['solc', '=node_modules/', '--ast', 'contracts/Shitcoin.sol']' returned non-zero exit status 1.``` 
Means that it found (probably the correct path), however you didn't specifiy it in the correct manner (I wish there was a better way of saying this or a link to send you). Basically, the rewrite rules are a pain, and they work best if you can use absolute path (which is why you'll see $pwd being used)

Try this: --solc-paths="zeppelin-solidity/=$(pwd)/node_modules/zeppelin-solidity/"

Yeah, that worked!

Thanks