rexdavinci / browser-solidity-compiler

18 stars 7 forks source link

Choose compiler version automatically #11

Open 0xaniol opened 9 months ago

0xaniol commented 9 months ago

I have been using this package for a while and I have bumped into a new need, maybe someone has been in the same situation and can help with it:

When I compile a flattened contract, which contains multiple contracts, I have to specify the compiler version to use. I would like to determine the compiler version according to the one specified in the contract, but when having multiple contracts this process gets messy. I am currently searching for all the "pragma solidity" occurrences in the flattened contract, storing all the versions and then filtering them in order to find the greater one. Apart from this solution being inefficient, it also has some flaws, for example, if the code has commented lines with the "pragma solidity" keyword.

I think it would be much more optimal to somehow determine an "automatic" option that used the correct compiler version to use when not being able to specify the version ourselves. Is this something that can be improved within the package? Or has someone found an efficient way of finding which compiler version to use for a flattened file with multiple contracts?