Skip to content

Commit 45ed438

Browse files
Fixed generating callback arguments for untyped operations (#185)
1 parent 3ddad5f commit 45ed438

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@ Please use [this](https://docs.gitlab.com/ee/development/changelog.html) documen
1414

1515
### Fixed
1616

17-
* cli: Fixed config not being verified when invoking some commands
17+
* cli: Fixed config not being verified when invoking some commands.
18+
* codegen: Fixed generating callback arguments for untyped operations.
1819
* index: Fixed incorrect log messages, remove duplicate ones.
1920
* index: Fixed crash while processing storage of some contracts.
21+
* index: Fixed matching of untyped operations filtered by `source` field ([@pravin-d](https://github.com/pravin-d)).
2022

2123
### Performance
2224

src/dipdup/config.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ def format_parameter_import(cls, package: str, module_name: str, entrypoint: str
322322
return f'{package}.types.{module_name}.parameter.{pascal_to_snake(entrypoint)}', parameter_cls
323323

324324
@classmethod
325-
def format_empty_operation_import(cls) -> Tuple[str, str]:
325+
def format_untyped_operation_import(cls) -> Tuple[str, str]:
326326
return 'dipdup.models', 'OperationData'
327327

328328
@classmethod
@@ -342,7 +342,7 @@ def format_operation_argument(cls, module_name: str, entrypoint: str, optional:
342342
return pascal_to_snake(entrypoint), f'Transaction[{parameter_cls}, {storage_cls}]'
343343

344344
@classmethod
345-
def format_empty_operation_argument(cls, transaction_id: int, optional: bool) -> Tuple[str, str]:
345+
def format_untyped_operation_argument(cls, transaction_id: int, optional: bool) -> Tuple[str, str]:
346346
if optional:
347347
return f'transaction_{transaction_id}', 'Optional[OperationData] = None'
348348
return f'transaction_{transaction_id}', 'OperationData'
@@ -449,14 +449,14 @@ def iter_imports(self, package: str) -> Iterator[Tuple[str, str]]:
449449
yield self.format_parameter_import(package, module_name, self.entrypoint)
450450
yield self.format_storage_import(package, module_name)
451451
else:
452-
yield self.format_empty_operation_import()
452+
yield self.format_untyped_operation_import()
453453

454454
def iter_arguments(self) -> Iterator[Tuple[str, str]]:
455455
if self.entrypoint:
456456
module_name = self.destination_contract_config.module_name
457457
yield self.format_operation_argument(module_name, self.entrypoint, self.optional)
458458
else:
459-
yield self.format_empty_operation_argument(self.transaction_id, self.optional)
459+
yield self.format_untyped_operation_argument(self.transaction_id, self.optional)
460460

461461
@cached_property
462462
def source_contract_config(self) -> ContractConfig:
@@ -1250,16 +1250,15 @@ def _resolve_index_links(self, index_config: IndexConfigT) -> None:
12501250
for handler_config in index_config.handlers:
12511251
handler_config.parent = index_config
12521252
self._callback_patterns[handler_config.callback].append(handler_config.pattern)
1253-
for pattern_config in handler_config.pattern:
1254-
transaction_id = 0
1253+
for idx, pattern_config in enumerate(handler_config.pattern):
1254+
# NOTE: Untyped operations are named as `transaction_N` based on their index
12551255
if isinstance(pattern_config, OperationHandlerTransactionPatternConfig):
12561256
if isinstance(pattern_config.destination, str):
12571257
pattern_config.destination = self.get_contract(pattern_config.destination)
12581258
if isinstance(pattern_config.source, str):
12591259
pattern_config.source = self.get_contract(pattern_config.source)
12601260
if not pattern_config.entrypoint:
1261-
pattern_config.transaction_id = transaction_id
1262-
transaction_id += 1
1261+
pattern_config.transaction_id = idx
12631262

12641263
elif isinstance(pattern_config, OperationHandlerOriginationPatternConfig):
12651264
if isinstance(pattern_config.source, str):

0 commit comments

Comments
 (0)