Skip to content

Commit 660946e

Browse files
Fixed invalid imports and arguments in generated big_map handlers (#171)
* Fix gcodegen of big_map index handlers * Changelog
1 parent 544b477 commit 660946e

File tree

3 files changed

+13
-12
lines changed

3 files changed

+13
-12
lines changed

CHANGELOG.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
# Changelog
22

3-
## 3.1.3 - [unreleased]
3+
## 3.1.3 - 2021-11-15
44

55
### Fixed
66

7-
* Fixed missing imports in handlers generated during init.
7+
* codegen: Fixed missing imports in operation handlers.
8+
* codegen: Fixed invalid imports and arguments in big_map handlers.
89

910
## 3.1.2 - 2021-11-02
1011

src/dipdup/config.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -667,21 +667,21 @@ def __post_init_post_parse__(self):
667667

668668
@classmethod
669669
def format_key_import(cls, package: str, module_name: str, path: str) -> Tuple[str, str]:
670-
key_cls = f'{snake_to_pascal(module_name)}Key'
671-
key_module = f'{path}_key'
670+
key_cls = f'{snake_to_pascal(path)}Key'
671+
key_module = f'{pascal_to_snake(path)}_key'
672672
return f'{package}.types.{module_name}.big_map.{key_module}', key_cls
673673

674674
@classmethod
675675
def format_value_import(cls, package: str, module_name: str, path: str) -> Tuple[str, str]:
676-
value_cls = f'{snake_to_pascal(module_name)}Value'
677-
value_module = f'{path}_value'
676+
value_cls = f'{snake_to_pascal(path)}Value'
677+
value_module = f'{pascal_to_snake(path)}_value'
678678
return f'{package}.types.{module_name}.big_map.{value_module}', value_cls
679679

680680
@classmethod
681-
def format_big_map_diff_argument(cls, module_name: str) -> Tuple[str, str]:
682-
key_cls = f'{snake_to_pascal(module_name)}Key'
683-
value_cls = f'{snake_to_pascal(module_name)}Value'
684-
return module_name, f'BigMapDiff[{key_cls}, {value_cls}]'
681+
def format_big_map_diff_argument(cls, path: str) -> Tuple[str, str]:
682+
key_cls = f'{snake_to_pascal(path)}Key'
683+
value_cls = f'{snake_to_pascal(path)}Value'
684+
return pascal_to_snake(path), f'BigMapDiff[{key_cls}, {value_cls}]'
685685

686686
def iter_imports(self, package: str) -> Iterator[Tuple[str, str]]:
687687
yield 'dipdup.context', 'HandlerContext'
@@ -693,7 +693,7 @@ def iter_imports(self, package: str) -> Iterator[Tuple[str, str]]:
693693

694694
def iter_arguments(self) -> Iterator[Tuple[str, str]]:
695695
yield 'ctx', 'HandlerContext'
696-
yield self.format_big_map_diff_argument(self.contract_config.module_name)
696+
yield self.format_big_map_diff_argument(self.path)
697697

698698
@property
699699
def contract_config(self) -> ContractConfig:

src/dipdup/utils/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ async def slowdown(seconds: int):
4444

4545
def snake_to_pascal(value: str) -> str:
4646
"""humps wrapper for Python imports"""
47-
return humps.pascalize(value)
47+
return humps.pascalize(value.replace('.', '_'))
4848

4949

5050
def pascal_to_snake(value: str) -> str:

0 commit comments

Comments
 (0)