|
37 | 37 | from urllib.parse import quote_plus |
38 | 38 | from urllib.parse import urlparse |
39 | 39 |
|
40 | | -from pydantic import Field |
41 | 40 | from pydantic import validator |
42 | 41 | from pydantic.dataclasses import dataclass |
43 | 42 | from pydantic.json import pydantic_encoder |
@@ -1155,7 +1154,9 @@ class TokenTransferHandlerConfig(HandlerConfig, kind='handler'): |
1155 | 1154 |
|
1156 | 1155 | contract: ContractConfig | None = None |
1157 | 1156 | token_id: int | None = None |
1158 | | - from_: ContractConfig | None = Field(default=None, alias='from') |
| 1157 | + # FIXME: Can't use `from_` field alias in dataclass; fixed in dipdup.yaml instead |
| 1158 | + # FIXME: See https://github.com/pydantic/pydantic/issues/4286 |
| 1159 | + from_: ContractConfig | None = None |
1159 | 1160 | to: ContractConfig | None = None |
1160 | 1161 |
|
1161 | 1162 | def iter_imports(self, package: str) -> Iterator[tuple[str, str]]: |
@@ -1856,16 +1857,14 @@ def _resolve_index_links(self, index_config: ResolvedIndexConfigU) -> None: |
1856 | 1857 | for token_transfer_handler_config in index_config.handlers: |
1857 | 1858 | token_transfer_handler_config.parent = index_config |
1858 | 1859 |
|
1859 | | - for attribute_name in ['contract', 'from_', 'to']: |
1860 | | - attribute_value = getattr(token_transfer_handler_config, attribute_name) |
1861 | | - if isinstance(attribute_value, str): |
1862 | | - setattr( |
1863 | | - token_transfer_handler_config, |
1864 | | - attribute_name, |
1865 | | - self.get_contract(attribute_value), |
1866 | | - ) |
| 1860 | + if isinstance(token_transfer_handler_config.contract, str): |
| 1861 | + token_transfer_handler_config.contract = self.get_contract(token_transfer_handler_config.contract) |
| 1862 | + |
| 1863 | + if isinstance(token_transfer_handler_config.from_, str): |
| 1864 | + token_transfer_handler_config.from_ = self.get_contract(token_transfer_handler_config.from_) |
1867 | 1865 |
|
1868 | | - assert token_transfer_handler_config |
| 1866 | + if isinstance(token_transfer_handler_config.to, str): |
| 1867 | + token_transfer_handler_config.to = self.get_contract(token_transfer_handler_config.to) |
1869 | 1868 |
|
1870 | 1869 | elif isinstance(index_config, OperationUnfilteredIndexConfig): |
1871 | 1870 | index_config.handler_config.parent = index_config |
|
0 commit comments