ApeWorX / py-solc-x

Python wrapper and version management tool for the solc Solidity compiler.
https://solcx.readthedocs.io/
MIT License
141 stars 49 forks source link

fix: _compile_combined_json should use the given version of solc #126

Closed qnnnnez closed 1 year ago

qnnnnez commented 3 years ago

What I did

Make _compile_combined_json use the correct version of solc. Currently it will always use default version of solc.

How I did it

Make _compile_combined_json accept an argument solc_binary.

How to verify it

Test script:

import solcx

solcx.install_solc('latest')
solcx.install_solc('0.6.6')
solcx.compile_source('', solc_version='0.6.6')

Running the test script with current master:

solcx.exceptions.UnknownValue: solc 0.6.6 does not accept 'function-debug
' as an option for the '--combined-json' flag

Running the test script with the fix:

> command: `/Users/wushuang/.solcx/solc-v0.6.6 --combined-json abi,asm,ast,bin,bin-runtime,compact-format,devdoc,hashes,interface,metadata,opcodes,srcmap,srcmap-runtime,storage-layout,userdoc -`
> return code: `0`
> stdout:
{"sourceList":["<stdin>"],"sources":{"<stdin>":{"AST":{"absolutePath":"<stdin>","exportedSymbols":{},"id":1,"nodeType":"SourceUnit","nodes":[],"src":"1:0:0"}}},"version":"0.6.6+commit.6c089d02.Darwin.appleclang"}

> stderr:
Warning: Source file does not specify required compiler version! Consider adding "pragma solidity ^0.6.6;"
 --> <stdin>

Checklist

antazoey commented 1 year ago

It looks like this got done somewhere else