Skip to content

Commit

Permalink
fix verbose.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Ouziel committed Jan 17, 2025
1 parent 81bd95c commit 0707ee1
Showing 1 changed file with 24 additions and 8 deletions.
32 changes: 24 additions & 8 deletions counterparty-core/counterpartycore/lib/api/verbose.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@ def inject_issuances_and_block_times(ledger_db, state_db, result_list):
item["params"][field_name_time] = block_times[item["params"][field_name]]
if "params" in item:
item = item["params"]
if "unpacked_data" in item:
if "unpacked_data" in item and item["unpacked_data"]:
item = item["unpacked_data"]["message_data"]
elif "unpacked_data" in item:
elif "unpacked_data" in item and item["unpacked_data"]:
item = item["unpacked_data"]["message_data"]
for field_name in asset_fields:
if isinstance(item, list):
Expand Down Expand Up @@ -225,15 +225,15 @@ def inject_normalized_quantities(result_list):
item["params"] = inject_normalized_quantity(
item["params"], field_name, {"divisible": field_info["divisible"]}
)
if "unpacked_data" in item["params"]:
if "unpacked_data" in item["params"] and item["params"]["unpacked_data"]:
item["params"]["unpacked_data"]["message_data"] = (
inject_normalized_quantity(
item["params"]["unpacked_data"]["message_data"],
field_name,
{"divisible": field_info["divisible"]},
)
)
if "unpacked_data" in item:
if "unpacked_data" in item and item["unpacked_data"]:
item["unpacked_data"]["message_data"] = inject_normalized_quantity(
item["unpacked_data"]["message_data"],
field_name,
Expand All @@ -251,8 +251,10 @@ def inject_normalized_quantities(result_list):
)
continue

if "unpacked_data" in item and isinstance(
item["unpacked_data"]["message_data"], list
if (
"unpacked_data" in item
and item["unpacked_data"]
and isinstance(item["unpacked_data"]["message_data"], list)
): # mpma send
for pos, sub_item in enumerate(item["unpacked_data"]["message_data"]):
if field_info["asset_field"] in sub_item:
Expand All @@ -264,6 +266,7 @@ def inject_normalized_quantities(result_list):
if (
"params" in item
and "unpacked_data" in item["params"]
and item["params"]["unpacked_data"]
and isinstance(item["params"]["unpacked_data"]["message_data"], list)
): # mpma send
for pos, sub_item in enumerate(item["params"]["unpacked_data"]["message_data"]):
Expand All @@ -281,13 +284,15 @@ def inject_normalized_quantities(result_list):
elif (
"params" in item
and "unpacked_data" in item["params"]
and item["params"]["unpacked_data"]
and field_info["asset_field"] in item["params"]["unpacked_data"]["message_data"]
):
asset_info = item["params"]["unpacked_data"]["message_data"][
field_info["asset_field"]
]
elif (
"unpacked_data" in item
and item["unpacked_data"]
and field_info["asset_field"] in item["unpacked_data"]["message_data"]
):
asset_info = item["unpacked_data"]["message_data"][field_info["asset_field"]]
Expand All @@ -297,7 +302,11 @@ def inject_normalized_quantities(result_list):
"params" in item and "divisible" in item["params"] and field_name in item["params"]
):
asset_info = {"divisible": item["params"]["divisible"]}
elif "unpacked_data" in item and "divisible" in item["unpacked_data"]["message_data"]:
elif (
"unpacked_data" in item
and item["unpacked_data"]
and "divisible" in item["unpacked_data"]["message_data"]
):
asset_info = {"divisible": item["unpacked_data"]["message_data"]["divisible"]}

if asset_info is None:
Expand All @@ -308,11 +317,13 @@ def inject_normalized_quantities(result_list):
elif (
"params" in item
and "unpacked_data" in item["params"]
and [item]["params"]["unpacked_data"]

Check warning

Code scanning / pylint

Sequence index is not an int, slice, or instance with index. Warning

Sequence index is not an int, slice, or instance with __index__.
and "asset_info" in item["params"]["unpacked_data"]["message_data"]
):
asset_info = item["params"]["unpacked_data"]["message_data"]["asset_info"]
elif (
"unpacked_data" in item
and item["unpacked_data"]
and "asset_info" in item["unpacked_data"]["message_data"]
):
asset_info = item["unpacked_data"]["message_data"]["asset_info"]
Expand All @@ -328,12 +339,17 @@ def inject_normalized_quantities(result_list):
if (
"params" in item
and "unpacked_data" in item["params"]
and item["params"]["unpacked_data"]
and field_name in item["params"]["unpacked_data"]["message_data"]
):
item["params"]["unpacked_data"]["message_data"] = inject_normalized_quantity( # noqa
item["params"]["unpacked_data"]["message_data"], field_name, asset_info
)
if "unpacked_data" in item and field_name in item["unpacked_data"]["message_data"]:
if (
"unpacked_data" in item
and item["unpacked_data"]
and field_name in item["unpacked_data"]["message_data"]
):
item["unpacked_data"]["message_data"] = inject_normalized_quantity( # noqa
item["unpacked_data"]["message_data"], field_name, asset_info
)
Expand Down

0 comments on commit 0707ee1

Please sign in to comment.