Skip to content

Commit bcdcbe3

Browse files
Added originated_contract_tzips field to OperationData (#350)
1 parent 0d425a4 commit bcdcbe3

File tree

5 files changed

+18
-4
lines changed

5 files changed

+18
-4
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## [unreleased]
4+
5+
### Added
6+
7+
* tzkt: Added `originated_contract_tzips` field to `OperationData`.
8+
39
## 5.1.1 - 2022-05-13
410

511
### Fixed

src/dipdup/datasources/tzkt/datasource.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1059,6 +1059,7 @@ def convert_operation(cls, operation_json: Dict[str, Any], type_: Optional[str]
10591059
originated_contract_address=originated_contract_json.get('address'),
10601060
originated_contract_type_hash=originated_contract_json.get('typeHash'),
10611061
originated_contract_code_hash=originated_contract_json.get('codeHash'),
1062+
originated_contract_tzips=originated_contract_json.get('tzips'),
10621063
storage=operation_json.get('storage'),
10631064
diffs=operation_json.get('diffs') or (),
10641065
delegate_address=delegate_json.get('address'),

src/dipdup/hasura.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ async def _get_fields(self, name: str = 'query_root') -> List[Field]:
377377
for field_json in fields_json:
378378
# NOTE: Exclude autogenerated aggregate and pk fields
379379
ignore_postfixes = ('_aggregate', '_by_pk', 'Aggregate', 'ByPk')
380-
if any(map(lambda postfix: field_json['name'].endswith(postfix), ignore_postfixes)):
380+
if any(map(lambda postfix: field_json['name'].endswith(postfix), ignore_postfixes)): # noqa: C417
381381
continue
382382

383383
# NOTE: Exclude relations. Not reliable enough but ok for now.
@@ -438,7 +438,7 @@ def _format_rest_query(self, name: str, table: str, filter: str, fields: Iterabl
438438
name = humps.camelize(name)
439439
filter = humps.camelize(filter)
440440
table = humps.camelize(table)
441-
map(lambda f: f.camelize(), fields)
441+
map(lambda f: f.camelize(), fields) # noqa: C417
442442

443443
try:
444444
filter_field = next(f for f in fields if f.name == filter)

src/dipdup/models.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ 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+
originated_contract_tzips: Optional[Tuple[str, ...]] = None
5556
delegate_address: Optional[str] = None
5657
delegate_alias: Optional[str] = None
5758

tests/test_dipdup/test_datasources/test_tzkt.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616

1717

1818
@asynccontextmanager
19-
async def with_tzkt(batch_size: int) -> AsyncIterator[TzktDatasource]:
19+
async def with_tzkt(batch_size: int, url: str | None = None) -> AsyncIterator[TzktDatasource]:
2020
config = HTTPConfig(batch_size=batch_size)
21-
datasource = TzktDatasource('https://api.tzkt.io', config)
21+
datasource = TzktDatasource(url or 'https://api.tzkt.io', config)
2222
async with datasource:
2323
yield datasource
2424

@@ -200,6 +200,12 @@ async def test_iter_migration_originations(self) -> None:
200200
self.assertEqual(67955553, originations[0].id)
201201
self.assertEqual(67955554, originations[1].id)
202202

203+
async def test_get_originations(self) -> None:
204+
async with with_tzkt(1, 'https://tzkt-mainnet.dipdup.net') as tzkt:
205+
originations = await tzkt.get_originations({'KT1PWx2mnDueood7fEmfbBDKx1D9BAnnXitn'}, 889027, 889027)
206+
self.assertEqual(23812803, originations[0].id)
207+
self.assertEqual(('fa12',), originations[0].originated_contract_tzips)
208+
203209
async def test_on_operation_message_data(self) -> None:
204210
with open(join(dirname(__file__), '..', 'ftzfun.json')) as f:
205211
operations_json = json.load(f)

0 commit comments

Comments
 (0)