Add a flattener for contracts
sz-piotr opened this issue · 1 comments
sz-piotr commented
Add a flattener for contracts
msieczko commented
Current Waffle CLI usage
Waffle CLI is currently used by passing in a path to a config file and doesn't have any meaningful options.
Usage:
waffle [config-file] [options]
Compiles solidity source code
Config file:
Read more about the configuration file in the documentation
https://ethereum-waffle.readthedocs.io
Options:
--help, -h Display this message
Possible solutions
1. Add waffle flatten
and waffle compile
CLI options and make waffle
invocation default to waffle compile
.
Usage:
waffle [compile|flatten] [config-file] [options]
Config file:
Read more about the configuration file in the documentation
https://ethereum-waffle.readthedocs.io
Options:
--help, -h Display this message
Pros:
- Easy to transform into third approach
Cons:
- User must provide multiple configs (for compile and flatten)
- Increased complexity:
compile
andflatten
configs should have separate formats to not introduce confusion. Not every field fromcompile
config is used for flattening (e.g.compilerVersion
oroutputType
)
2. Add single option to waffle config flattenOutputDirectory
.
Usage would be the same as currently
Cons:
- if we add
flattenOutputDirectory
it would make more sense to renameoutputDirectory
->compileOutputDirectory
- user may want to flatten only some of the files from sourceDirectory and would end up creating a separate config file anyway
3. Add support for multiple configurations along with waffle flatten
and waffle compile
commands (involves: #209)
The configuration format would now allow adding multiple configurations in an array. Passing a single configuration object would still be possible to maintain backwards compatibility.
[
{
name: "old contracts",
type: "compile",
compilerVersion: "0.4.19",
sourceDirectory: "src/old-contracts",
outputDirectory: "dist/old-contracts",
},
{
name: "new contracts",
type: "compile",
compilerVersion: "0.6.3",
sourceDirectory: "src/new-contracts",
outputDirectory: "dist/new-contracts",
},
{
name: "flatten",
type: "flatten",
sourceDirectory: "src/new-contracts",
outputDirectory: "dist/new-contracts/flat",
},
]
New optional configuration fields would be added:
name
(default:#1
position in array) - for better printing of waffle processing progresstype
(default:compile
) - for choosing processing action: compilation or flattening of contracts fromsourceDirectory
The new usage of Waffle CLI would look as follows:
Usage:
waffle [compile|flatten] [config-file] [options]
Config file:
Read more about the configuration file in the documentation
https://ethereum-waffle.readthedocs.io
Options:
--help, -h Display this message
Invoking waffle compile
command would run only configs with type compile
.
Invoking waffle flatten
would run only configs with type flatten
.
Invoking waffle
would run all specified configurations.