Skip to content

Commit 1c5a4c3

Browse files
Merge branch 'release/v2.8.0'
2 parents c673de1 + e34de3f commit 1c5a4c3

23 files changed

+274
-79
lines changed

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
# Changelog
22

3+
# v2.8.0
4+
5+
<!-- Release notes generated using configuration in .github/release.yml at release/v2.8.0 -->
6+
7+
## What's Changed
8+
### Enhancements
9+
* Blockheaders: Support for blockheaders call against Indexer API. by @gmalouf in https://github.com/algorand/py-algorand-sdk/pull/553
10+
* API: Support for header-only flag on /v2/block algod endpoint. by @gmalouf in https://github.com/algorand/py-algorand-sdk/pull/557
11+
12+
## New Contributors
13+
* @dependabot made their first contribution in https://github.com/algorand/py-algorand-sdk/pull/535
14+
15+
**Full Changelog**: https://github.com/algorand/py-algorand-sdk/compare/v2.7.0...v2.8.0
16+
317
# v2.7.0
418

519
<!-- Release notes generated using configuration in .github/release.yml at release/v2.7.0 -->

algosdk/abi/tuple_type.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -232,9 +232,9 @@ def decode(self, bytestring: Union[bytes, bytearray]) -> list:
232232
"value string must be in bytes: {}".format(bytestring)
233233
)
234234
tuple_elements = self.child_types
235-
dynamic_segments: List[
236-
List[int]
237-
] = list() # Store the start and end of a dynamic element
235+
dynamic_segments: List[List[int]] = (
236+
list()
237+
) # Store the start and end of a dynamic element
238238
value_partitions: List[Optional[Union[bytes, bytearray]]] = list()
239239
i = 0
240240
array_index = 0

algosdk/atomic_transaction_composer.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -679,9 +679,9 @@ def gather_signatures(self) -> List[GenericSignedTransaction]:
679679
stxn_list: List[Optional[GenericSignedTransaction]] = [None] * len(
680680
self.txn_list
681681
)
682-
signer_indexes: Dict[
683-
TransactionSigner, List[int]
684-
] = {} # Map a signer to a list of indices to sign
682+
signer_indexes: Dict[TransactionSigner, List[int]] = (
683+
{}
684+
) # Map a signer to a list of indices to sign
685685
txn_list = self.build_group()
686686
for i, txn_with_signer in enumerate(txn_list):
687687
if txn_with_signer.signer not in signer_indexes:

algosdk/transaction.py

Lines changed: 36 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -220,9 +220,9 @@ def undictify(d):
220220
"sender": encoding.encode_address(d["snd"]),
221221
"note": d["note"] if "note" in d else None,
222222
"lease": d["lx"] if "lx" in d else None,
223-
"rekey_to": encoding.encode_address(d["rekey"])
224-
if "rekey" in d
225-
else None,
223+
"rekey_to": (
224+
encoding.encode_address(d["rekey"]) if "rekey" in d else None
225+
),
226226
}
227227
txn_type = d["type"]
228228
if not isinstance(d["type"], str):
@@ -394,13 +394,15 @@ def dictify(self):
394394
@staticmethod
395395
def _undictify(d):
396396
args = {
397-
"close_remainder_to": encoding.encode_address(d["close"])
398-
if "close" in d
399-
else None,
397+
"close_remainder_to": (
398+
encoding.encode_address(d["close"]) if "close" in d else None
399+
),
400400
"amt": d["amt"] if "amt" in d else 0,
401-
"receiver": encoding.encode_address(d["rcv"])
402-
if "rcv" in d
403-
else constants.ZERO_ADDRESS,
401+
"receiver": (
402+
encoding.encode_address(d["rcv"])
403+
if "rcv" in d
404+
else constants.ZERO_ADDRESS
405+
),
404406
}
405407
return args
406408

@@ -1169,7 +1171,6 @@ def __init__(
11691171

11701172

11711173
class AssetFreezeTxn(Transaction):
1172-
11731174
"""
11741175
Represents a transaction for freezing or unfreezing an account's asset
11751176
holdings. Must be issued by the asset's freeze manager.
@@ -1367,17 +1368,19 @@ def dictify(self):
13671368
@staticmethod
13681369
def _undictify(d):
13691370
args = {
1370-
"receiver": encoding.encode_address(d["arcv"])
1371-
if "arcv" in d
1372-
else constants.ZERO_ADDRESS,
1371+
"receiver": (
1372+
encoding.encode_address(d["arcv"])
1373+
if "arcv" in d
1374+
else constants.ZERO_ADDRESS
1375+
),
13731376
"amt": d["aamt"] if "aamt" in d else 0,
13741377
"index": d["xaid"] if "xaid" in d else None,
1375-
"close_assets_to": encoding.encode_address(d["aclose"])
1376-
if "aclose" in d
1377-
else None,
1378-
"revocation_target": encoding.encode_address(d["asnd"])
1379-
if "asnd" in d
1380-
else None,
1378+
"close_assets_to": (
1379+
encoding.encode_address(d["aclose"]) if "aclose" in d else None
1380+
),
1381+
"revocation_target": (
1382+
encoding.encode_address(d["asnd"]) if "asnd" in d else None
1383+
),
13811384
}
13821385

13831386
return args
@@ -1685,22 +1688,24 @@ def _undictify(d):
16851688
args = {
16861689
"index": d["apid"] if "apid" in d else None,
16871690
"on_complete": d["apan"] if "apan" in d else None,
1688-
"local_schema": StateSchema.undictify(d["apls"])
1689-
if "apls" in d
1690-
else None,
1691-
"global_schema": StateSchema.undictify(d["apgs"])
1692-
if "apgs" in d
1693-
else None,
1691+
"local_schema": (
1692+
StateSchema.undictify(d["apls"]) if "apls" in d else None
1693+
),
1694+
"global_schema": (
1695+
StateSchema.undictify(d["apgs"]) if "apgs" in d else None
1696+
),
16941697
"approval_program": d["apap"] if "apap" in d else None,
16951698
"clear_program": d["apsu"] if "apsu" in d else None,
16961699
"app_args": d["apaa"] if "apaa" in d else None,
16971700
"accounts": d["apat"] if "apat" in d else None,
16981701
"foreign_apps": d["apfa"] if "apfa" in d else None,
16991702
"foreign_assets": d["apas"] if "apas" in d else None,
17001703
"extra_pages": d["apep"] if "apep" in d else 0,
1701-
"boxes": [BoxReference.undictify(box) for box in d["apbx"]]
1702-
if "apbx" in d
1703-
else None,
1704+
"boxes": (
1705+
[BoxReference.undictify(box) for box in d["apbx"]]
1706+
if "apbx" in d
1707+
else None
1708+
),
17041709
}
17051710
if args["accounts"]:
17061711
args["accounts"] = [
@@ -2303,9 +2308,9 @@ def merge(
23032308
for s in range(len(stx.multisig.subsigs)):
23042309
if stx.multisig.subsigs[s].signature:
23052310
if not msigstx.multisig.subsigs[s].signature:
2306-
msigstx.multisig.subsigs[
2307-
s
2308-
].signature = stx.multisig.subsigs[s].signature
2311+
msigstx.multisig.subsigs[s].signature = (
2312+
stx.multisig.subsigs[s].signature
2313+
)
23092314
elif (
23102315
not msigstx.multisig.subsigs[s].signature
23112316
== stx.multisig.subsigs[s].signature

algosdk/v2client/algod.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,7 @@ def block_info(
270270
block: Optional[int] = None,
271271
response_format: str = "json",
272272
round_num: Optional[int] = None,
273+
header_only: Optional[bool] = None,
273274
**kwargs: Any,
274275
) -> AlgodResponseType:
275276
"""
@@ -280,8 +281,15 @@ def block_info(
280281
response_format (str): the format in which the response is
281282
returned: either "json" or "msgpack"
282283
round_num (int, optional): alias for block; specify one of these
284+
header_only (bool, optional): if set to true, only block header would be
285+
present in the the response
286+
283287
"""
284288
query = {"format": response_format}
289+
290+
if header_only:
291+
query["header-only"] = "true"
292+
285293
req = "/blocks/" + _specify_round_string(block, round_num)
286294
res = self.algod_request(
287295
"GET", req, query, response_format=response_format, **kwargs

algosdk/v2client/indexer.py

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,64 @@ def search_transactions(
566566

567567
return self.indexer_request("GET", req, query, **kwargs)
568568

569+
def search_block_headers(
570+
self,
571+
limit=None,
572+
next_page=None,
573+
min_round=None,
574+
max_round=None,
575+
start_time=None,
576+
end_time=None,
577+
proposers=None,
578+
absent=None,
579+
expired=None,
580+
**kwargs
581+
):
582+
"""
583+
Return a list of block headers satisfying the conditions.
584+
585+
Args:
586+
limit (int, optional): maximum number of results to return
587+
next_page (str, optional): the next page of results; use the next
588+
token provided by the previous results
589+
min_round (int, optional): include results at or after the
590+
specified round
591+
max_round (int, optional): include results at or before the
592+
specified round
593+
start_time (str, optional): include results after the given time;
594+
must be an RFC 3339 formatted string
595+
end_time (str, optional): include results before the given time;
596+
must be an RFC 3339 formatted string
597+
proposers (list, optional): include results with accounts marked as
598+
proposers in the block header's participation updates
599+
expired (list, optional): include results with accounts marked as
600+
expired in the block header's participation updates
601+
absent (list, optional): include results with accounts marked as
602+
absent in the block header's participation updates
603+
"""
604+
req = "/block-headers"
605+
query = dict()
606+
if limit:
607+
query["limit"] = limit
608+
if next_page:
609+
query["next"] = next_page
610+
if min_round:
611+
query["min-round"] = min_round
612+
if max_round:
613+
query["max-round"] = max_round
614+
if end_time:
615+
query["before-time"] = end_time
616+
if start_time:
617+
query["after-time"] = start_time
618+
if proposers:
619+
query["proposers"] = proposers
620+
if expired:
621+
query["expired"] = expired
622+
if absent:
623+
query["absent"] = absent
624+
625+
return self.indexer_request("GET", req, query, **kwargs)
626+
569627
def search_transactions_by_address(
570628
self,
571629
address,

algosdk/v2client/models/account.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -504,9 +504,11 @@ def dictify(self):
504504
elif isinstance(value, dict):
505505
result[oas_attr] = dict(
506506
map(
507-
lambda item: (item[0], item[1].dictify())
508-
if hasattr(item[1], "dictify")
509-
else item,
507+
lambda item: (
508+
(item[0], item[1].dictify())
509+
if hasattr(item[1], "dictify")
510+
else item
511+
),
510512
value.items(),
511513
)
512514
)

algosdk/v2client/models/account_participation.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -212,9 +212,11 @@ def dictify(self):
212212
elif isinstance(value, dict):
213213
result[oas_attr] = dict(
214214
map(
215-
lambda item: (item[0], item[1].dictify())
216-
if hasattr(item[1], "dictify")
217-
else item,
215+
lambda item: (
216+
(item[0], item[1].dictify())
217+
if hasattr(item[1], "dictify")
218+
else item
219+
),
218220
value.items(),
219221
)
220222
)

algosdk/v2client/models/application.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,11 @@ def dictify(self):
8888
elif isinstance(value, dict):
8989
result[oas_attr] = dict(
9090
map(
91-
lambda item: (item[0], item[1].dictify())
92-
if hasattr(item[1], "dictify")
93-
else item,
91+
lambda item: (
92+
(item[0], item[1].dictify())
93+
if hasattr(item[1], "dictify")
94+
else item
95+
),
9496
value.items(),
9597
)
9698
)

algosdk/v2client/models/application_local_state.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,11 @@ def dictify(self):
117117
elif isinstance(value, dict):
118118
result[oas_attr] = dict(
119119
map(
120-
lambda item: (item[0], item[1].dictify())
121-
if hasattr(item[1], "dictify")
122-
else item,
120+
lambda item: (
121+
(item[0], item[1].dictify())
122+
if hasattr(item[1], "dictify")
123+
else item
124+
),
123125
value.items(),
124126
)
125127
)

algosdk/v2client/models/application_params.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,9 +211,11 @@ def dictify(self):
211211
elif isinstance(value, dict):
212212
result[oas_attr] = dict(
213213
map(
214-
lambda item: (item[0], item[1].dictify())
215-
if hasattr(item[1], "dictify")
216-
else item,
214+
lambda item: (
215+
(item[0], item[1].dictify())
216+
if hasattr(item[1], "dictify")
217+
else item
218+
),
217219
value.items(),
218220
)
219221
)

algosdk/v2client/models/application_state_schema.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,11 @@ def dictify(self):
9393
elif isinstance(value, dict):
9494
result[oas_attr] = dict(
9595
map(
96-
lambda item: (item[0], item[1].dictify())
97-
if hasattr(item[1], "dictify")
98-
else item,
96+
lambda item: (
97+
(item[0], item[1].dictify())
98+
if hasattr(item[1], "dictify")
99+
else item
100+
),
99101
value.items(),
100102
)
101103
)

algosdk/v2client/models/asset.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,11 @@ def dictify(self):
8888
elif isinstance(value, dict):
8989
result[oas_attr] = dict(
9090
map(
91-
lambda item: (item[0], item[1].dictify())
92-
if hasattr(item[1], "dictify")
93-
else item,
91+
lambda item: (
92+
(item[0], item[1].dictify())
93+
if hasattr(item[1], "dictify")
94+
else item
95+
),
9496
value.items(),
9597
)
9698
)

algosdk/v2client/models/asset_holding.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,11 @@ def dictify(self):
152152
elif isinstance(value, dict):
153153
result[oas_attr] = dict(
154154
map(
155-
lambda item: (item[0], item[1].dictify())
156-
if hasattr(item[1], "dictify")
157-
else item,
155+
lambda item: (
156+
(item[0], item[1].dictify())
157+
if hasattr(item[1], "dictify")
158+
else item
159+
),
158160
value.items(),
159161
)
160162
)

algosdk/v2client/models/asset_params.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -389,9 +389,11 @@ def dictify(self):
389389
elif isinstance(value, dict):
390390
result[oas_attr] = dict(
391391
map(
392-
lambda item: (item[0], item[1].dictify())
393-
if hasattr(item[1], "dictify")
394-
else item,
392+
lambda item: (
393+
(item[0], item[1].dictify())
394+
if hasattr(item[1], "dictify")
395+
else item
396+
),
395397
value.items(),
396398
)
397399
)

0 commit comments

Comments
 (0)