Make py-solc-x select the lowest matching solc version
- Dominant language
- Python
- Stars
- 142
- Forks
- 50
- PR merge metrics
- No merged PRs in 30d
Description
### Overview
Currently, `solc.install.install_solc_pragma(pragma_string)` installs the newest available Solidity version that matches the given pragma. In some situations, it is preferable to use the *lowest* matching version instead. First, it is natural for programmers to put that solc version into the pragma that they are actually using, prefixing it with a `^`. So selecting the lowest version will ensure that an authentic version is selected. There are cases where a later version of solc introduced breaking changes (while still in the same `0.x.*` series), by changing a warning to an error. Second, some programmers mistakenly prefix the version by `>=` instead of `^`, such that `py-solc-x` most certainly will select the wrong version.
### Specification
Add a flag `favor_earlier_version`, default `False`, to methods like `install_solc_pragma` and hand it down to routines like `get_installable_solc_versions` (to sort versions in increasing order) and to `_select_pragma_version` (to influence the comparison of `version` and `selected`. This modification is backwards compatible.
Contributor guide
Assessment
This issue has not been assessed yet.