diff --git a/app/api/middleware.py b/app/api/middleware.py index 5e3d6b5..2574df5 100644 --- a/app/api/middleware.py +++ b/app/api/middleware.py @@ -75,6 +75,16 @@ async def try_authorization(request): except: pass + try: + activity_meta["args"] = dict(request.args) + except: + pass + + try: + activity_meta["json"] = dict(request.json) + except: + pass + try: activity_meta["method"] = request.method except: @@ -95,7 +105,7 @@ async def try_authorization(request): type="API_V1_REQUEST", meta=activity_meta, user_id=user.id, - user_ip=request.ip, + user_ip=activity_meta.get("ip", "0.0.0.0"), created=datetime.now() ) request.ctx.db_session.add(new_user_activity) diff --git a/app/core/background/indexer_service.py b/app/core/background/indexer_service.py index 03a14f1..d2d8de6 100644 --- a/app/core/background/indexer_service.py +++ b/app/core/background/indexer_service.py @@ -49,7 +49,7 @@ async def indexer_loop(memory, platform_found: bool, seqno: int) -> [bool, int]: make_log("Indexer", f"Last known index: {last_known_index}", level="debug") next_item_index = last_known_index + 1 - resolve_item_result = await toncenter.run_get_method(platform.address.to_string(1, 1, 1), 'get_nft_address_by_index', [['num', hex(next_item_index)[2:]]]) + resolve_item_result = await toncenter.run_get_method(platform.address.to_string(1, 1, 1), 'get_nft_address_by_index', [['num', (lambda x: (lambda y: (f"0{y}" if len(y) % 2 else y))(hex(x)[2:]))(next_item_index)]]) if resolve_item_result.get('exit_code', -1) != 0: make_log("Indexer", f"Resolve item error: {resolve_item_result}", level="error") return platform_found, seqno diff --git a/app/core/content/content_id.py b/app/core/content/content_id.py index 75a485f..cb53baa 100644 --- a/app/core/content/content_id.py +++ b/app/core/content/content_id.py @@ -43,10 +43,7 @@ class ContentId: + self.content_hash ) if not (self.safe_onchain_index is None): - oi_bin_hex = hex(self.safe_onchain_index)[2:] - if len(oi_bin_hex) % 2 == 1: - oi_bin_hex = '0' + oi_bin_hex - + oi_bin_hex = (lambda x: (lambda y: (f"0{y}" if len(y) % 2 else y))(hex(x)[2:]))(self.safe_onchain_index) oi_bin_len = len(oi_bin_hex) // 2 cid_bin += b'\xb0' + oi_bin_len.to_bytes(1, 'big') + bytes.fromhex(oi_bin_hex) if self.accept_type and include_accept_type: