Skip to content

Commit f82b162

Browse files
committed
Add support for sort param to get transactions endpoint
1 parent 81239ca commit f82b162

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

fireblocks_sdk/sdk.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ def deposit_from_linked_dda(self, account_id, amount, idempotency_key=None):
326326

327327
def get_transactions_with_page_info(self, before=0, after=None, status=None, limit=None, txhash=None,
328328
assets=None, source_type=None, source_id=None, dest_type=None, dest_id=None,
329-
next_or_previous_path=None):
329+
next_or_previous_path=None, sort=None):
330330
"""Gets a list of transactions matching the given filters or path.
331331
Note that "next_or_previous_path" is mutually exclusive with other parameters.
332332
If you wish to iterate over the nextPage/prevPage pages, please provide only the "next_or_previous_path" parameter from `pageDetails` response
@@ -352,6 +352,8 @@ def get_transactions_with_page_info(self, before=0, after=None, status=None, lim
352352
NETWORK_CONNECTION, COMPOUND
353353
dest_id (str, optional): Only gets transactions with given dest_id
354354
next_or_previous_path (str, optional): get transactions matching the path, provided from pageDetails
355+
sort (str, optional): Possible values are ASC or DESC, DESC is the default behavior for getting transaction
356+
from latests to the oldest.
355357
"""
356358
if next_or_previous_path is not None:
357359
if not next_or_previous_path:
@@ -362,10 +364,10 @@ def get_transactions_with_page_info(self, before=0, after=None, status=None, lim
362364
return self._get_request(suffix_path, True)
363365
else:
364366
return self._get_transactions(before, after, status, limit, None, txhash, assets, source_type, source_id,
365-
dest_type, dest_id, True)
367+
dest_type, dest_id, sort, True)
366368

367369
def get_transactions(self, before=0, after=0, status=None, limit=None, order_by=None, txhash=None,
368-
assets=None, source_type=None, source_id=None, dest_type=None, dest_id=None):
370+
assets=None, source_type=None, source_id=None, dest_type=None, dest_id=None, sort=None):
369371
"""Gets a list of transactions matching the given filters
370372
371373
Args:
@@ -387,12 +389,14 @@ def get_transactions(self, before=0, after=0, status=None, limit=None, order_by=
387389
VAULT_ACCOUNT, EXCHANGE_ACCOUNT, INTERNAL_WALLET, EXTERNAL_WALLET, UNKNOWN_PEER, FIAT_ACCOUNT,
388390
NETWORK_CONNECTION, COMPOUND
389391
dest_id (str, optional): Only gets transactions with given dest_id
392+
sort (str, optional): Possible values are ASC or DESC, DESC is the default behavior for getting transaction
393+
from latests to the oldest.
390394
"""
391395
return self._get_transactions(before, after, status, limit, order_by, txhash, assets, source_type, source_id,
392-
dest_type, dest_id)
396+
dest_type, dest_id, sort)
393397

394398
def _get_transactions(self, before, after, status, limit, order_by, txhash, assets, source_type, source_id,
395-
dest_type, dest_id, page_mode=False):
399+
dest_type, dest_id, sort, page_mode=False):
396400
path = "/v1/transactions"
397401
params = {}
398402

@@ -421,6 +425,8 @@ def _get_transactions(self, before, after, status, limit, order_by, txhash, asse
421425
params['destType'] = dest_type
422426
if dest_id:
423427
params['destId'] = dest_id
428+
if sort:
429+
params['sort'] = sort
424430
if params:
425431
path = path + "?" + urllib.parse.urlencode(params)
426432

0 commit comments

Comments
 (0)