Skip to content

Commit 7bce7e2

Browse files
committed
Split models
1 parent 87046a8 commit 7bce7e2

15 files changed

+326
-309
lines changed

solc_select/infrastructure/filesystem.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from pathlib import Path
1111

1212
from ..constants import ARTIFACTS_DIR, SOLC_SELECT_DIR
13-
from ..models import SolcVersion
13+
from ..models.versions import SolcVersion
1414

1515

1616
class FilesystemManager:

solc_select/models.py

Lines changed: 0 additions & 300 deletions
This file was deleted.

solc_select/models/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
"""
2+
Domain models for solc-select.
3+
4+
This package contains the core business entities and value objects organized by concern.
5+
"""

solc_select/models/artifacts.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
"""Artifact-related domain models."""
2+
3+
from dataclasses import dataclass
4+
from pathlib import Path
5+
6+
from packaging.version import Version
7+
8+
from ..platform_capabilities import EmulationCapability
9+
from .platforms import Platform
10+
from .versions import SolcVersion
11+
12+
13+
@dataclass(kw_only=True)
14+
class SolcArtifactOnDisk:
15+
"""Represents a Solidity compiler artifact on disk."""
16+
17+
version: SolcVersion
18+
platform: Platform
19+
file_path: Path
20+
emulation: EmulationCapability | None = None # Emulation info if not native
21+
22+
23+
@dataclass(kw_only=True)
24+
class SolcArtifact(SolcArtifactOnDisk):
25+
"""Represents a downloadable Solidity compiler artifact."""
26+
27+
download_url: str
28+
checksum_sha256: str
29+
checksum_keccak256: str | None
30+
31+
def __post_init__(self) -> None:
32+
"""Validate artifact properties."""
33+
if not self.download_url:
34+
raise ValueError("Download URL cannot be empty")
35+
if not self.checksum_sha256:
36+
raise ValueError("SHA256 checksum cannot be empty")
37+
if self.checksum_sha256.startswith("0x"):
38+
# Normalize by removing 0x prefix
39+
object.__setattr__(self, "checksum_sha256", self.checksum_sha256[2:])
40+
if self.checksum_keccak256 and self.checksum_keccak256.startswith("0x"):
41+
# Normalize by removing 0x prefix
42+
object.__setattr__(self, "checksum_keccak256", self.checksum_keccak256[2:])
43+
44+
@property
45+
def is_zip_archive(self) -> bool:
46+
"""Check if this artifact is a ZIP archive (older Windows versions)."""
47+
return self.platform.os_type == "windows" and self.version <= Version("0.7.1")
48+
49+
def get_binary_name_in_zip(self) -> str:
50+
"""Get the binary name inside ZIP archives."""
51+
if not self.is_zip_archive:
52+
raise ValueError("Not a ZIP archive")
53+
return "solc.exe"

0 commit comments

Comments
 (0)