|
|
@ -1,7 +1,7 @@ |
|
|
|
import logging |
|
|
|
import logging |
|
|
|
import re |
|
|
|
import re |
|
|
|
import solc |
|
|
|
import solc |
|
|
|
import solcx |
|
|
|
import sys |
|
|
|
import os |
|
|
|
import os |
|
|
|
|
|
|
|
|
|
|
|
from ethereum import utils |
|
|
|
from ethereum import utils |
|
|
@ -14,6 +14,9 @@ from mythril.ethereum.evmcontract import EVMContract |
|
|
|
from mythril.ethereum.interface.rpc.exceptions import ConnectionError |
|
|
|
from mythril.ethereum.interface.rpc.exceptions import ConnectionError |
|
|
|
from mythril.solidity.soliditycontract import SolidityContract, get_contracts_from_file |
|
|
|
from mythril.solidity.soliditycontract import SolidityContract, get_contracts_from_file |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if sys.version_info[1] >= 6: |
|
|
|
|
|
|
|
import solcx |
|
|
|
|
|
|
|
|
|
|
|
log = logging.getLogger(__name__) |
|
|
|
log = logging.getLogger(__name__) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -67,22 +70,29 @@ class MythrilDisassembler: |
|
|
|
): |
|
|
|
): |
|
|
|
log.info("Given version is already installed") |
|
|
|
log.info("Given version is already installed") |
|
|
|
else: |
|
|
|
else: |
|
|
|
try: |
|
|
|
|
|
|
|
if version.startswith("0.4"): |
|
|
|
if version.startswith("0.4"): |
|
|
|
|
|
|
|
try: |
|
|
|
solc.install_solc("v" + version) |
|
|
|
solc.install_solc("v" + version) |
|
|
|
else: |
|
|
|
|
|
|
|
solcx.install_solc("v" + version) |
|
|
|
|
|
|
|
solc_binary = util.solc_exists(version) |
|
|
|
|
|
|
|
if not solc_binary: |
|
|
|
|
|
|
|
raise solc.exceptions.SolcError() |
|
|
|
|
|
|
|
except solc.exceptions.SolcError: |
|
|
|
except solc.exceptions.SolcError: |
|
|
|
raise CriticalError( |
|
|
|
raise CriticalError( |
|
|
|
"There was an error when trying to install the specified solc version" |
|
|
|
"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) |
|
|
|
except solcx.exceptions.SolcError: |
|
|
|
except solcx.exceptions.SolcError: |
|
|
|
raise CriticalError( |
|
|
|
raise CriticalError( |
|
|
|
"There was an error when trying to install the specified solc version" |
|
|
|
"There was an error when trying to install the specified solc version" |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
else: |
|
|
|
|
|
|
|
raise CriticalError( |
|
|
|
|
|
|
|
"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) |
|
|
|
log.info("Setting the compiler to %s", solc_binary) |
|
|
|
|
|
|
|
|
|
|
|