Skip to content

Commit 4e0da4c

Browse files
committed
Fix parsing of multiple asset that has an empty asset name in Ogmios
1 parent bea3047 commit 4e0da4c

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

pycardano/backend/ogmios.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,15 @@ def _check_utxo_unspent(self, tx_id: str, index: int) -> bool:
362362
return len(results) > 0
363363

364364
def _extract_asset_info(self, asset_hash: str) -> Tuple[str, ScriptHash, AssetName]:
365-
policy_hex, asset_name_hex = asset_hash.split(".")
365+
split_result = asset_hash.split(".")
366+
367+
if len(split_result) == 1:
368+
policy_hex, asset_name_hex = split_result[0], ""
369+
elif len(split_result) == 2:
370+
policy_hex, asset_name_hex = split_result
371+
else:
372+
raise ValueError(f"Unable to parse asset hash: {asset_hash}")
373+
366374
policy = ScriptHash.from_primitive(policy_hex)
367375
asset_name = AssetName.from_primitive(asset_name_hex)
368376

test/pycardano/backend/test_ogmios.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
"126b8676446c84a5cd6e3259223b16a2314c5676b88ae1c1f8579a8f.744d494e": 762462,
7777
"57fca08abbaddee36da742a839f7d83a7e1d2419f1507fcbf3916522.43484f43": 9945000,
7878
"fc3ef8db4a16c1959fbabfcbc3fb7669bf315967ffef260ececc47a3.53484942": 1419813131821,
79+
"fc3ef8db4a16c1959fbabfcbc3fb7669bf315967ffef260ececc47a3": 1234,
7980
},
8081
},
8182
"datum": None,
@@ -194,7 +195,8 @@ def test_utxo(self, chain_context):
194195
"43484f43": 9945000
195196
},
196197
"fc3ef8db4a16c1959fbabfcbc3fb7669bf315967ffef260ececc47a3": {
197-
"53484942": 1419813131821
198+
"53484942": 1419813131821,
199+
b"": 1234,
198200
},
199201
}
200202
)

0 commit comments

Comments
 (0)