|
|
|
@ -1,7 +1,7 @@ |
|
|
|
|
import logging |
|
|
|
|
import re |
|
|
|
|
import solc |
|
|
|
|
import solcx |
|
|
|
|
import sys |
|
|
|
|
import os |
|
|
|
|
|
|
|
|
|
from ethereum import utils |
|
|
|
@ -14,6 +14,9 @@ from mythril.ethereum.evmcontract import EVMContract |
|
|
|
|
from mythril.ethereum.interface.rpc.exceptions import ConnectionError |
|
|
|
|
from mythril.solidity.soliditycontract import SolidityContract, get_contracts_from_file |
|
|
|
|
|
|
|
|
|
if sys.version_info[1] >= 6: |
|
|
|
|
import solcx |
|
|
|
|
|
|
|
|
|
log = logging.getLogger(__name__) |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -67,23 +70,30 @@ class MythrilDisassembler: |
|
|
|
|
): |
|
|
|
|
log.info("Given version is already installed") |
|
|
|
|
else: |
|
|
|
|
try: |
|
|
|
|
if version.startswith("0.4"): |
|
|
|
|
if version.startswith("0.4"): |
|
|
|
|
try: |
|
|
|
|
solc.install_solc("v" + version) |
|
|
|
|
else: |
|
|
|
|
except solc.exceptions.SolcError: |
|
|
|
|
raise CriticalError( |
|
|
|
|
"There was an error when trying to install the specified solc version" |
|
|
|
|
) |
|
|
|
|
elif sys.version_info[1] >= 6: |
|
|
|
|
# solcx supports python 3.6+ |
|
|
|
|
try: |
|
|
|
|
solcx.install_solc("v" + version) |
|
|
|
|
solc_binary = util.solc_exists(version) |
|
|
|
|
if not solc_binary: |
|
|
|
|
raise solc.exceptions.SolcError() |
|
|
|
|
except solc.exceptions.SolcError: |
|
|
|
|
raise CriticalError( |
|
|
|
|
"There was an error when trying to install the specified solc version" |
|
|
|
|
) |
|
|
|
|
except solcx.exceptions.SolcError: |
|
|
|
|
except solcx.exceptions.SolcError: |
|
|
|
|
raise CriticalError( |
|
|
|
|
"There was an error when trying to install the specified solc version" |
|
|
|
|
) |
|
|
|
|
else: |
|
|
|
|
raise CriticalError( |
|
|
|
|
"There was an error when trying to install the specified solc version" |
|
|
|
|
"Py-Solc doesn't support 0.5.*. You can switch to python 3.6 which uses solcx." |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
solc_binary = util.solc_exists(version) |
|
|
|
|
if not solc_binary: |
|
|
|
|
raise solc.exceptions.SolcError() |
|
|
|
|
|
|
|
|
|
log.info("Setting the compiler to %s", solc_binary) |
|
|
|
|
|
|
|
|
|
return solc_binary |
|
|
|
|