My contracts have some methods that used only for testing i.e. exposes some internal contract data and I do not want to deploy it to live network. for now Solidity does not supports C-style preprocessor instructions like #if/#else
. But on npmjs I found module preprocessor that does exactly what I want.
Only one question remains - how to compile contract after preprocessing? Obviously I cannot replace original contract and in the same time want to keep resulting artifacts file with same name as original contract. Maybe it is possible to compile contracts from stdin
so I can chain preprocessor output to truffle input?
2_preprocess_contracts.js
that will call the preprocessor and output the contracts. Then have the real migration script in the next step3_deploy_contracts.js
. You can use the 'network' option to select different configurations inside your deployment scripts. – Ismael May 18 '18 at 14:01