Skip to content

Commit

Permalink
Fix verbose=true with asset_longname
Browse files Browse the repository at this point in the history
  • Loading branch information
Ouziel committed Dec 25, 2024
1 parent 3d7e570 commit a67d401
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 9 deletions.
36 changes: 27 additions & 9 deletions counterparty-core/counterpartycore/lib/ledger.py
Original file line number Diff line number Diff line change
Expand Up @@ -865,14 +865,27 @@ def get_asset_issuances_quantity(db, asset):


def get_assets_last_issuance(state_db, asset_list):
assets_info = []
cursor = state_db.cursor()
fields = ["asset", "asset_longname", "description", "issuer", "divisible", "locked"]
query = f"""
SELECT {", ".join(fields)} FROM assets_info
WHERE asset IN ({",".join(["?"] * len(asset_list))})
""" # nosec B608 # noqa: S608
cursor.execute(query, asset_list)
assets_info = cursor.fetchall()

asset_name_list = [asset for asset in asset_list if asset and "." not in asset]
if len(asset_name_list) > 0:
query = f"""
SELECT {", ".join(fields)} FROM assets_info
WHERE asset IN ({",".join(["?"] * len(asset_name_list))})
""" # nosec B608 # noqa: S608
cursor.execute(query, asset_name_list)
assets_info += cursor.fetchall()

asset_longname_list = [asset for asset in asset_list if asset and "." in asset]
if len(asset_longname_list) > 0:
query = f"""
SELECT {", ".join(fields)} FROM assets_info
WHERE asset_longname IN ({",".join(["?"] * len(asset_longname_list))})
""" # nosec B608 # noqa: S608
cursor.execute(query, asset_longname_list)
assets_info += cursor.fetchall()

result = {
"BTC": {
Expand All @@ -891,9 +904,14 @@ def get_assets_last_issuance(state_db, asset_list):
},
}
for asset_info in assets_info:
asset = asset_info["asset"]
del asset_info["asset"]
result[asset] = asset_info
if asset_info["asset_longname"] in asset_list:
result[asset_info["asset_longname"]] = asset_info
result[asset_info["asset"]] = asset_info
else:
asset = asset_info["asset"]
del asset_info["asset"]
result[asset] = asset_info

return result


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6534,6 +6534,7 @@
"fee_required": 900000,
"status": "open",
"give_asset_info": {
"asset": "XCP",
"asset_longname": null,
"description": "The Counterparty protocol native currency",
"issuer": null,
Expand Down
1 change: 1 addition & 0 deletions release-notes/release-notes-v10.9.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
- Catch errors correctly when composing MPMA send
- Fix query to fill `issuances.asset_events` field
- Fix `assets_info.supply` field
- Fix `verbose=True` when `give_asset` or `get_asset` contain an `asset_longname`

## Codebase

Expand Down

0 comments on commit a67d401

Please sign in to comment.