RyuuGan / sol-merger

Merges all imports into single file for solidity contracts
BSD 2-Clause "Simplified" License
157 stars 22 forks source link

feat: auto add appropriate Solidity version pragma if root file doesn't have #42

Open yxliang01 opened 4 years ago

yxliang01 commented 4 years ago

There might be case that the root file has no pragma for specifying Solidity version while its imports have. It might not make sense to not putting any pragma in this case. What can be done is to use semver library to parse all imports' Solidity requirement, then find the expression that is the minimum among all specifications. i.e. find the intersection between all specifications.

RyuuGan commented 4 years ago

Hello @yxliang01,

Sorry for late response. I didn't have internet for a while.

I can see that they might be not resolvable, because some of the libraries can have dependencies with strict pragma version, for example, this 2 pragmas might not be compatible:

pragma solidity >=0.4.0 <0.5.0
pragma solidity ^0.6.0

In that case the issue will still preserve.

Best regards, Valerii Aligorskii

yxliang01 commented 4 years ago

Under such case, I think it makes sense to throw an error since the merged contract shouldn't be successfully compiled by design.