Skip to content

Commit

Permalink
feat!: update cached compilers improvements [APE-1500] (#1721)
Browse files Browse the repository at this point in the history
  • Loading branch information
antazoey authored Dec 16, 2023
1 parent 40796d6 commit e6821c3
Show file tree
Hide file tree
Showing 19 changed files with 404 additions and 161 deletions.
4 changes: 2 additions & 2 deletions docs/userguides/compile.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ By default, Ape ignores files `package.json`, `package-lock.json`, `tsconfig.jso
To override this list, edit your `ape-config.yaml` similarly:

```yaml
compiler:
ignore_files:
compile:
exclude:
- "*package.json"
- "*package-lock.json"
- "*tsconfig.json"
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
"web3[tester]>=6.12.0,<7",
# ** Dependencies maintained by ApeWorX **
"eip712>=0.2.3,<0.4",
"ethpm-types>=0.6.2,<0.7",
"ethpm-types>=0.6.3,<0.7",
"eth_pydantic_types>=0.1.0a4,<0.2",
"evm-trace>=0.1.0",
],
Expand Down
22 changes: 11 additions & 11 deletions src/ape/api/compiler.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from functools import cached_property
from pathlib import Path
from typing import Dict, Iterator, List, Optional, Set, Tuple
from typing import Dict, Iterator, List, Optional, Sequence, Set, Tuple

from eth_pydantic_types import HexBytes
from ethpm_types import ContractType
Expand Down Expand Up @@ -54,27 +54,27 @@ def settings(self) -> PluginConfig:
return CustomConfig.model_validate(data)

@abstractmethod
def get_versions(self, all_paths: List[Path]) -> Set[str]:
def get_versions(self, all_paths: Sequence[Path]) -> Set[str]:
"""
Retrieve the set of available compiler versions for this plugin to compile ``all_paths``.
Args:
all_paths (List[pathlib.Path]): The list of paths.
all_paths (Sequence[pathlib.Path]): The list of paths.
Returns:
Set[str]: A set of available compiler versions.
"""

@raises_not_implemented
def get_compiler_settings( # type: ignore[empty-body]
self, contract_filepaths: List[Path], base_path: Optional[Path] = None
self, contract_filepaths: Sequence[Path], base_path: Optional[Path] = None
) -> Dict[Version, Dict]:
"""
Get a mapping of the settings that would be used to compile each of the sources
by the compiler version number.
Args:
contract_filepaths (List[pathlib.Path]): The list of paths.
contract_filepaths (Sequence[pathlib.Path]): The list of paths.
base_path (Optional[pathlib.Path]): The contracts folder base path.
Returns:
Expand All @@ -83,13 +83,13 @@ def get_compiler_settings( # type: ignore[empty-body]

@abstractmethod
def compile(
self, contract_filepaths: List[Path], base_path: Optional[Path]
self, contract_filepaths: Sequence[Path], base_path: Optional[Path]
) -> List[ContractType]:
"""
Compile the given source files. All compiler plugins must implement this function.
Args:
contract_filepaths (List[pathlib.Path]): A list of source file paths to compile.
contract_filepaths (Sequence[pathlib.Path]): A list of source file paths to compile.
base_path (Optional[pathlib.Path]): Optionally provide the base path, such as the
project ``contracts/`` directory. Defaults to ``None``. When using in a project
via ``ape compile``, gets set to the project's ``contracts/`` directory.
Expand Down Expand Up @@ -122,14 +122,14 @@ def compile_code( # type: ignore[empty-body]

@raises_not_implemented
def get_imports( # type: ignore[empty-body]
self, contract_filepaths: List[Path], base_path: Optional[Path]
self, contract_filepaths: Sequence[Path], base_path: Optional[Path]
) -> Dict[str, List[str]]:
"""
Returns a list of imports as source_ids for each contract's source_id in a given
compiler.
Args:
contract_filepaths (List[pathlib.Path]): A list of source file paths to compile.
contract_filepaths (Sequence[pathlib.Path]): A list of source file paths to compile.
base_path (Optional[pathlib.Path]): Optionally provide the base path, such as the
project ``contracts/`` directory. Defaults to ``None``. When using in a project
via ``ape compile``, gets set to the project's ``contracts/`` directory.
Expand All @@ -141,14 +141,14 @@ def get_imports( # type: ignore[empty-body]
@raises_not_implemented
def get_version_map( # type: ignore[empty-body]
self,
contract_filepaths: List[Path],
contract_filepaths: Sequence[Path],
base_path: Optional[Path] = None,
) -> Dict[Version, Set[Path]]:
"""
Get a map of versions to source paths.
Args:
contract_filepaths (List[Path]): Input source paths. Defaults to all source paths
contract_filepaths (Sequence[Path]): Input source paths. Defaults to all source paths
per compiler.
base_path (Path): The base path of sources. Defaults to the project's
``contracts_folder``.
Expand Down
5 changes: 3 additions & 2 deletions src/ape/api/networks.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
Iterator,
List,
Optional,
Sequence,
Tuple,
Type,
Union,
Expand Down Expand Up @@ -362,12 +363,12 @@ def encode_transaction(
"""

@abstractmethod
def decode_logs(self, logs: List[Dict], *events: EventABI) -> Iterator["ContractLog"]:
def decode_logs(self, logs: Sequence[Dict], *events: EventABI) -> Iterator["ContractLog"]:
"""
Decode any contract logs that match the given event ABI from the raw log data.
Args:
logs (List[Dict]): A list of raw log data from the chain.
logs (Sequence[Dict]): A list of raw log data from the chain.
*events (EventABI): Event definitions to decode.
Returns:
Expand Down
Loading

0 comments on commit e6821c3

Please sign in to comment.