crytic_compile.compiler.compiler
Handle the compiler version
1"""Handle the compiler version 2""" 3import logging 4from typing import Optional 5from solc_select.solc_select import installed_versions, install_artifacts 6 7LOGGER = logging.getLogger("CryticCompile") 8 9# pylint: disable=too-few-public-methods 10class CompilerVersion: 11 """ 12 Class representing the compiler information 13 """ 14 15 def __init__( 16 self, 17 compiler: str, 18 version: Optional[str], 19 optimized: Optional[bool], 20 optimize_runs: Optional[int] = None, 21 ) -> None: 22 """ 23 Initialize a compier version object 24 25 Args: 26 compiler (str): compiler (in most of the case use "solc") 27 version (str): compiler version 28 optimized (Optional[bool]): true if optimization are enabled 29 optimize_runs (Optional[int]): optimize runs number 30 """ 31 self.compiler: str = compiler 32 self.version: Optional[str] = version 33 self.optimized: Optional[bool] = optimized 34 self.optimize_runs: Optional[int] = optimize_runs 35 36 def look_for_installed_version(self) -> None: 37 """ 38 This function queries solc-select to see if the current compiler version is installed 39 And if its not it will install it 40 41 Returns: 42 43 """ 44 if self.version not in installed_versions(): 45 # TODO: check that the solc version was installed. 46 # Blocked by https://github.com/crytic/solc-select/issues/143 47 install_artifacts([self.version])
LOGGER =
<Logger CryticCompile (WARNING)>
class
CompilerVersion:
11class CompilerVersion: 12 """ 13 Class representing the compiler information 14 """ 15 16 def __init__( 17 self, 18 compiler: str, 19 version: Optional[str], 20 optimized: Optional[bool], 21 optimize_runs: Optional[int] = None, 22 ) -> None: 23 """ 24 Initialize a compier version object 25 26 Args: 27 compiler (str): compiler (in most of the case use "solc") 28 version (str): compiler version 29 optimized (Optional[bool]): true if optimization are enabled 30 optimize_runs (Optional[int]): optimize runs number 31 """ 32 self.compiler: str = compiler 33 self.version: Optional[str] = version 34 self.optimized: Optional[bool] = optimized 35 self.optimize_runs: Optional[int] = optimize_runs 36 37 def look_for_installed_version(self) -> None: 38 """ 39 This function queries solc-select to see if the current compiler version is installed 40 And if its not it will install it 41 42 Returns: 43 44 """ 45 if self.version not in installed_versions(): 46 # TODO: check that the solc version was installed. 47 # Blocked by https://github.com/crytic/solc-select/issues/143 48 install_artifacts([self.version])
Class representing the compiler information
CompilerVersion( compiler: str, version: Union[str, NoneType], optimized: Union[bool, NoneType], optimize_runs: Union[int, NoneType] = None)
16 def __init__( 17 self, 18 compiler: str, 19 version: Optional[str], 20 optimized: Optional[bool], 21 optimize_runs: Optional[int] = None, 22 ) -> None: 23 """ 24 Initialize a compier version object 25 26 Args: 27 compiler (str): compiler (in most of the case use "solc") 28 version (str): compiler version 29 optimized (Optional[bool]): true if optimization are enabled 30 optimize_runs (Optional[int]): optimize runs number 31 """ 32 self.compiler: str = compiler 33 self.version: Optional[str] = version 34 self.optimized: Optional[bool] = optimized 35 self.optimize_runs: Optional[int] = optimize_runs
Initialize a compier version object
Args: compiler (str): compiler (in most of the case use "solc") version (str): compiler version optimized (Optional[bool]): true if optimization are enabled optimize_runs (Optional[int]): optimize runs number
def
look_for_installed_version(self) -> None:
37 def look_for_installed_version(self) -> None: 38 """ 39 This function queries solc-select to see if the current compiler version is installed 40 And if its not it will install it 41 42 Returns: 43 44 """ 45 if self.version not in installed_versions(): 46 # TODO: check that the solc version was installed. 47 # Blocked by https://github.com/crytic/solc-select/issues/143 48 install_artifacts([self.version])
This function queries solc-select to see if the current compiler version is installed And if its not it will install it
Returns: