|
| 1 | +""" |
| 2 | +Backward compatibility wrappers for solc-select. |
| 3 | +
|
| 4 | +This module provides compatibility functions for code that previously imported |
| 5 | +from solc_select.solc_select, such as crytic-compile. These functions wrap |
| 6 | +the new refactored service architecture to maintain the same API. |
| 7 | +""" |
| 8 | + |
| 9 | +from pathlib import Path |
| 10 | +from typing import List |
| 11 | + |
| 12 | +from .constants import ARTIFACTS_DIR |
| 13 | +from .services.solc_service import SolcService |
| 14 | + |
| 15 | + |
| 16 | +def install_artifacts(versions: List[str], silent: bool = False) -> bool: |
| 17 | + """Install solc versions (backward compatibility wrapper). |
| 18 | +
|
| 19 | + Args: |
| 20 | + versions: List of version strings to install (e.g., ["0.8.19", "latest", "all"]) |
| 21 | + silent: Whether to suppress output messages |
| 22 | +
|
| 23 | + Returns: |
| 24 | + True if all installations succeeded, False otherwise |
| 25 | + """ |
| 26 | + service = SolcService() |
| 27 | + return service.install_versions(versions, silent) |
| 28 | + |
| 29 | + |
| 30 | +def installed_versions() -> List[str]: |
| 31 | + """Get list of installed version strings (backward compatibility wrapper). |
| 32 | +
|
| 33 | + Returns: |
| 34 | + List of installed version strings sorted by version number |
| 35 | + """ |
| 36 | + service = SolcService() |
| 37 | + versions = service.get_installed_versions() |
| 38 | + return [str(version) for version in versions] |
| 39 | + |
| 40 | + |
| 41 | +def artifact_path(version: str) -> Path: |
| 42 | + """Get the path to a version's binary (backward compatibility wrapper). |
| 43 | +
|
| 44 | + Args: |
| 45 | + version: Version string (e.g., "0.8.19") |
| 46 | +
|
| 47 | + Returns: |
| 48 | + Path to the solc binary for the given version |
| 49 | +
|
| 50 | + Note: |
| 51 | + This function returns the expected path regardless of whether |
| 52 | + the version is actually installed, matching the original behavior. |
| 53 | + """ |
| 54 | + return ARTIFACTS_DIR / f"solc-{version}" / f"solc-{version}" |
0 commit comments