Skip to content

Commit 2e37304

Browse files
authored
Support for filtering /transactions by group-id. (#577)
1 parent 46484fd commit 2e37304

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

algosdk/v2client/indexer.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,7 @@ def search_transactions(
477477
address_role=None,
478478
exclude_close_to=False,
479479
application_id=None,
480+
group_id=None,
480481
rekey_to=False,
481482
round_num=None,
482483
**kwargs
@@ -524,6 +525,7 @@ def search_transactions(
524525
to true
525526
application_id (int, optional): filter for transactions pertaining
526527
to an application
528+
group_id (bytes, optional): filter transactions by group id
527529
rekey_to (bool, optional): include results which include the
528530
rekey-to field
529531
round_num (int, optional): alias for block; only specify one of
@@ -566,6 +568,8 @@ def search_transactions(
566568
query["exclude-close-to"] = "true"
567569
if application_id:
568570
query["application-id"] = application_id
571+
if group_id:
572+
query["group-id"] = base64.b64encode(group_id).decode()
569573
if rekey_to:
570574
query["rekey-to"] = "true"
571575

tests/steps/other_v2_steps.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,7 @@ def parse_asset(context, index):
728728

729729

730730
@when(
731-
'we make a Search For Transactions call with account "{account:MaybeString}" NotePrefix "{notePrefixB64:MaybeString}" TxType "{txType:MaybeString}" SigType "{sigType:MaybeString}" txid "{txid:MaybeString}" round {block} minRound {minRound} maxRound {maxRound} limit {limit} beforeTime "{beforeTime:MaybeString}" afterTime "{afterTime:MaybeString}" currencyGreaterThan {currencyGreaterThan} currencyLessThan {currencyLessThan} assetIndex {index} addressRole "{addressRole:MaybeString}" ExcluseCloseTo "{excludeCloseTo:MaybeString}" rekeyTo "{rekeyTo:MaybeString}"'
731+
'we make a Search For Transactions call with account "{account:MaybeString}" NotePrefix "{notePrefixB64:MaybeString}" TxType "{txType:MaybeString}" SigType "{sigType:MaybeString}" txid "{txid:MaybeString}" round {block} minRound {minRound} maxRound {maxRound} limit {limit} beforeTime "{beforeTime:MaybeString}" afterTime "{afterTime:MaybeString}" currencyGreaterThan {currencyGreaterThan} currencyLessThan {currencyLessThan} assetIndex {index} addressRole "{addressRole:MaybeString}" ExcluseCloseTo "{excludeCloseTo:MaybeString}" groupid "{groupidB64:MaybeString}" rekeyTo "{rekeyTo:MaybeString}"'
732732
)
733733
def search_txns(
734734
context,
@@ -748,6 +748,7 @@ def search_txns(
748748
index,
749749
addressRole,
750750
excludeCloseTo,
751+
groupidB64,
751752
rekeyTo,
752753
):
753754
if notePrefixB64 == "none":
@@ -768,6 +769,8 @@ def search_txns(
768769
addressRole = None
769770
if excludeCloseTo == "none":
770771
excludeCloseTo = None
772+
if groupidB64 == "none":
773+
groupidB64 = ""
771774
if rekeyTo == "none":
772775
rekeyTo = None
773776
context.response = context.icl.search_transactions(
@@ -788,12 +791,13 @@ def search_txns(
788791
address=account,
789792
address_role=addressRole,
790793
exclude_close_to=excludeCloseTo,
794+
group_id=base64.b64decode(groupidB64),
791795
rekey_to=rekeyTo,
792796
)
793797

794798

795799
@when(
796-
'we make a Search For Transactions call with account "{account:MaybeString}" NotePrefix "{notePrefixB64:MaybeString}" TxType "{txType:MaybeString}" SigType "{sigType:MaybeString}" txid "{txid:MaybeString}" round {block} minRound {minRound} maxRound {maxRound} limit {limit} beforeTime "{beforeTime:MaybeString}" afterTime "{afterTime:MaybeString}" currencyGreaterThan {currencyGreaterThan} currencyLessThan {currencyLessThan} assetIndex {index} addressRole "{addressRole:MaybeString}" ExcluseCloseTo "{excludeCloseTo:MaybeString}"'
800+
'we make a Search For Transactions call with account "{account:MaybeString}" NotePrefix "{notePrefixB64:MaybeString}" TxType "{txType:MaybeString}" SigType "{sigType:MaybeString}" txid "{txid:MaybeString}" round {block} minRound {minRound} maxRound {maxRound} limit {limit} beforeTime "{beforeTime:MaybeString}" afterTime "{afterTime:MaybeString}" currencyGreaterThan {currencyGreaterThan} currencyLessThan {currencyLessThan} assetIndex {index} addressRole "{addressRole:MaybeString}" ExcluseCloseTo "{excludeCloseTo:MaybeString}" groupid "{groupidB64:MaybeString}"'
797801
)
798802
def search_txns2(
799803
context,
@@ -813,6 +817,7 @@ def search_txns2(
813817
index,
814818
addressRole,
815819
excludeCloseTo,
820+
groupidB64,
816821
):
817822
if notePrefixB64 == "none":
818823
notePrefixB64 = ""
@@ -832,6 +837,8 @@ def search_txns2(
832837
addressRole = None
833838
if excludeCloseTo == "none":
834839
excludeCloseTo = None
840+
if groupidB64 == "none":
841+
groupidB64 = ""
835842
context.response = context.icl.search_transactions(
836843
asset_id=int(index),
837844
limit=int(limit),
@@ -850,6 +857,7 @@ def search_txns2(
850857
address=account,
851858
address_role=addressRole,
852859
exclude_close_to=excludeCloseTo,
860+
group_id=base64.b64decode(groupidB64),
853861
rekey_to=None,
854862
)
855863

0 commit comments

Comments
 (0)