From 8942ebe4afdbbbd1196edbf43f6889f7c5516b58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Eckel?= Date: Mon, 6 Mar 2023 15:11:53 +0100 Subject: [PATCH] fixed object differentiation issue in eventify_block (#350) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fixed object differentiation issue in eventify_block Signed-off-by: Jürgen Eckel --- planetmint/web/websocket_dispatcher.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/planetmint/web/websocket_dispatcher.py b/planetmint/web/websocket_dispatcher.py index e3a7840..8342b04 100644 --- a/planetmint/web/websocket_dispatcher.py +++ b/planetmint/web/websocket_dispatcher.py @@ -57,8 +57,12 @@ class Dispatcher: @staticmethod def eventify_block(block): for tx in block["transactions"]: - if tx.assets: - asset_ids = [asset.get("id", tx.id) for asset in tx.assets] + asset_ids = [] + if isinstance(tx.assets, dict): + asset_ids.append(tx.assets) + elif isinstance(tx.assets, list): + for asset in tx.assets: + asset_ids.append(asset.get("id", tx.id)) else: asset_ids = [tx.id] yield {"height": block["height"], "asset_ids": asset_ids, "transaction_id": tx.id}