diff --git a/CHANGELOG.md b/CHANGELOG.md index ce8dca4fe..20615d281 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,8 @@ The format is based on [Keep a Changelog], and this project adheres to [Semantic ### Fixed -- ci: Fixed falling `test_metadata_networks()` +- codegen: Added correct support of dots in typenames. +- ci: Fixed falling `test_metadata_networks()`. ## [7.3.1] - 2024-01-29 diff --git a/src/dipdup/codegen/evm_subsquid.py b/src/dipdup/codegen/evm_subsquid.py index c208bf6bb..6e0566546 100644 --- a/src/dipdup/codegen/evm_subsquid.py +++ b/src/dipdup/codegen/evm_subsquid.py @@ -58,6 +58,7 @@ def jsonschema_from_abi(abi: dict[str, Any]) -> dict[str, Any]: def convert_abi(package: DipDupPackage, events: set[str], functions: set[str]) -> None: for abi_path in package.abi.glob('**/abi.json'): abi = orjson.loads(abi_path.read_bytes()) + abi_dirname = abi_path.relative_to(package.abi).parent event_extras: defaultdict[str, EventAbiExtra] = defaultdict(EventAbiExtra) # type: ignore[arg-type] for abi_item in abi: @@ -66,7 +67,7 @@ def convert_abi(package: DipDupPackage, events: set[str], functions: set[str]) - if name not in functions: continue schema = jsonschema_from_abi(abi_item) - schema_path = package.schemas / abi_path.parent.stem / 'evm_functions' / f'{abi_item["name"]}.json' + schema_path = package.schemas / abi_dirname / 'evm_functions' / f'{abi_item["name"]}.json' elif abi_item['type'] == 'event': name = abi_item['name'] if name in event_extras: @@ -81,7 +82,7 @@ def convert_abi(package: DipDupPackage, events: set[str], functions: set[str]) - continue schema = jsonschema_from_abi(abi_item) - schema_path = package.schemas / abi_path.parent.stem / 'evm_events' / f'{abi_item["name"]}.json' + schema_path = package.schemas / abi_dirname / 'evm_events' / f'{abi_item["name"]}.json' else: continue @@ -89,7 +90,7 @@ def convert_abi(package: DipDupPackage, events: set[str], functions: set[str]) - schema_path.write_bytes(json_dumps(schema)) if event_extras: - event_extras_path = package.abi / abi_path.parent.stem / 'events.json' + event_extras_path = package.abi / abi_dirname / 'events.json' touch(event_extras_path) event_extras_path.write_bytes(json_dumps(event_extras)) @@ -139,7 +140,7 @@ async def _fetch_abi(self, index_config: SubsquidEventsIndexConfig) -> None: datasource_configs = self._config.abi_datasources for handler_config in index_config.handlers: - abi_path = self._package.abi / handler_config.contract.module_name / 'abi.json' + abi_path = self._package.abi / handler_config.contract.module_path / 'abi.json' if abi_path.exists(): continue diff --git a/src/dipdup/config/__init__.py b/src/dipdup/config/__init__.py index 37cfc1b63..021b8c208 100644 --- a/src/dipdup/config/__init__.py +++ b/src/dipdup/config/__init__.py @@ -51,9 +51,9 @@ from dipdup.utils import pascal_to_snake from dipdup.yaml import DipDupYAMLConfig +from pathlib import Path if TYPE_CHECKING: from collections.abc import Iterator - from pathlib import Path from dipdup.subscriptions import Subscription @@ -242,6 +242,10 @@ class ContractConfig(ABC, NameMixin): def module_name(self) -> str: return self.typename or self.name + @property + def module_path(self) -> Path: + return Path(*self.module_name.split('.')) + class DatasourceConfig(ABC, NameMixin): kind: str