Skip to content

Commit aa6bc02

Browse files
Fix OperationData.amount, add delegate fields (#197)
1 parent b4adaf0 commit aa6bc02

File tree

4 files changed

+17
-1
lines changed

4 files changed

+17
-1
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@
22

33
Please use [this](https://docs.gitlab.com/ee/development/changelog.html) document as guidelines to keep a changelog.
44

5+
## [unreleased]
6+
7+
## Added
8+
9+
* tzkt: Added optional `delegate_address` and `delegate_alias` fields to `OperationData`.
10+
11+
## Fixed
12+
13+
* tzkt: Fixed incorrect parsing of `OperationData.amount` field.
14+
515
## 4.0.1 - 2021-12-30
616

717
## Fixed

src/dipdup/datasources/tzkt/datasource.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,7 @@ def convert_operation(cls, operation_json: Dict[str, Any], type_: Optional[str]
680680
sender_json = operation_json.get('sender') or {}
681681
target_json = operation_json.get('target') or {}
682682
initiator_json = operation_json.get('initiator') or {}
683+
delegate_json = operation_json.get('delegate') or {}
683684
parameter_json = operation_json.get('parameter') or {}
684685
originated_contract_json = operation_json.get('originatedContract') or {}
685686

@@ -703,7 +704,7 @@ def convert_operation(cls, operation_json: Dict[str, Any], type_: Optional[str]
703704
sender_address=sender_json.get('address'),
704705
target_address=target_json.get('address'),
705706
initiator_address=initiator_json.get('address'),
706-
amount=operation_json.get('amount') or operation_json.get('contractBalance'),
707+
amount=operation_json.get('amount', operation_json.get('contractBalance')),
707708
status=operation_json['status'],
708709
has_internals=operation_json.get('hasInternals'),
709710
sender_alias=operation_json['sender'].get('alias'),
@@ -717,6 +718,8 @@ def convert_operation(cls, operation_json: Dict[str, Any], type_: Optional[str]
717718
originated_contract_code_hash=originated_contract_json.get('codeHash'),
718719
storage=operation_json.get('storage'),
719720
diffs=operation_json.get('diffs') or (),
721+
delegate_address=delegate_json.get('address'),
722+
delegate_alias=delegate_json.get('alias'),
720723
)
721724

722725
@classmethod

src/dipdup/datasources/tzkt/enums.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class TzktMessageType(Enum):
2323
"status",
2424
"hasInternals",
2525
"diffs",
26+
"delegate",
2627
)
2728
ORIGINATION_MIGRATION_FIELDS = (
2829
"id",

src/dipdup/models.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ class OperationData:
5252
originated_contract_alias: Optional[str] = None
5353
originated_contract_type_hash: Optional[int] = None
5454
originated_contract_code_hash: Optional[int] = None
55+
delegate_address: Optional[str] = None
56+
delegate_alias: Optional[str] = None
5557

5658

5759
@dataclass

0 commit comments

Comments
 (0)