Skip to content

Commit

Permalink
Add forward_asset and backward_asset parameters for get order matches…
Browse files Browse the repository at this point in the history
… by asset endpoint
  • Loading branch information
Ouziel committed Dec 17, 2024
1 parent 132876f commit 956643b
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
19 changes: 16 additions & 3 deletions counterparty-core/counterpartycore/lib/api/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -2909,6 +2909,8 @@ def get_order_matches_by_asset(
state_db,
asset: str,
status: OrderMatchesStatus = "all",
forward_asset: str = None,
backward_asset: str = None,
cursor: str = None,
limit: int = 100,
offset: int = None,
Expand All @@ -2918,14 +2920,25 @@ def get_order_matches_by_asset(
Returns the orders of an asset
:param str asset: The asset to return (e.g. XCP)
:param str status: The status of the order matches to return
:param str forward_asset: The forward asset to return
:param str backward_asset: The backward asset to return
:param str cursor: The last index of the order matches to return
:param int limit: The maximum number of order matches to return (e.g. 5)
:param int offset: The number of lines to skip before returning results (overrides the `cursor` parameter)
:param str sort: The sort order of the order matches to return (overrides the `cursor` parameter) (e.g. forward_quantity:desc)
"""
where = prepare_order_matches_where(
status, {"forward_asset": asset.upper()}
) + prepare_order_matches_where(status, {"backward_asset": asset.upper()})
if forward_asset:
where = prepare_order_matches_where(
status, {"forward_asset": forward_asset.upper(), "backward_asset": asset.upper()}
)
elif backward_asset:
where = prepare_order_matches_where(
status, {"forward_asset": asset.upper(), "backward_asset": backward_asset.upper()}
)
else:
where = prepare_order_matches_where(
status, {"forward_asset": asset.upper()}
) + prepare_order_matches_where(status, {"backward_asset": asset.upper()})

return select_rows(
state_db,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16964,6 +16964,20 @@
],
"description": "The status of the orders to return"
},
{
"name": "get_asset",
"default": null,
"required": false,
"type": "str",
"description": "The get asset to return"
},
{
"name": "give_asset",
"default": null,
"required": false,
"type": "str",
"description": "The give asset to return"
},
{
"name": "cursor",
"default": 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 @@ -22,6 +22,7 @@

- Throw Error if BTC Quantity in Dispense isn't enough to Trigger Dispenser
- Add `get_asset` and `give_asset` parameters for get orders by asset endpoint
- Add `forward_asset` and `backward_asset` parameters for get order matches by asset endpoint

## CLI

Expand Down

0 comments on commit 956643b

Please sign in to comment.