Skip to content

Commit

Permalink
Merge branch 'release/v2.8.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Algo-devops-service committed Feb 13, 2025
2 parents c673de1 + e34de3f commit 1c5a4c3
Show file tree
Hide file tree
Showing 23 changed files with 274 additions and 79 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# Changelog

# v2.8.0

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

## What's Changed
### Enhancements
* Blockheaders: Support for blockheaders call against Indexer API. by @gmalouf in https://github.com/algorand/py-algorand-sdk/pull/553
* API: Support for header-only flag on /v2/block algod endpoint. by @gmalouf in https://github.com/algorand/py-algorand-sdk/pull/557

## New Contributors
* @dependabot made their first contribution in https://github.com/algorand/py-algorand-sdk/pull/535

**Full Changelog**: https://github.com/algorand/py-algorand-sdk/compare/v2.7.0...v2.8.0

# v2.7.0

<!-- Release notes generated using configuration in .github/release.yml at release/v2.7.0 -->
Expand Down
6 changes: 3 additions & 3 deletions algosdk/abi/tuple_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,9 @@ def decode(self, bytestring: Union[bytes, bytearray]) -> list:
"value string must be in bytes: {}".format(bytestring)
)
tuple_elements = self.child_types
dynamic_segments: List[
List[int]
] = list() # Store the start and end of a dynamic element
dynamic_segments: List[List[int]] = (
list()
) # Store the start and end of a dynamic element
value_partitions: List[Optional[Union[bytes, bytearray]]] = list()
i = 0
array_index = 0
Expand Down
6 changes: 3 additions & 3 deletions algosdk/atomic_transaction_composer.py
Original file line number Diff line number Diff line change
Expand Up @@ -679,9 +679,9 @@ def gather_signatures(self) -> List[GenericSignedTransaction]:
stxn_list: List[Optional[GenericSignedTransaction]] = [None] * len(
self.txn_list
)
signer_indexes: Dict[
TransactionSigner, List[int]
] = {} # Map a signer to a list of indices to sign
signer_indexes: Dict[TransactionSigner, List[int]] = (
{}
) # Map a signer to a list of indices to sign
txn_list = self.build_group()
for i, txn_with_signer in enumerate(txn_list):
if txn_with_signer.signer not in signer_indexes:
Expand Down
67 changes: 36 additions & 31 deletions algosdk/transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,9 @@ def undictify(d):
"sender": encoding.encode_address(d["snd"]),
"note": d["note"] if "note" in d else None,
"lease": d["lx"] if "lx" in d else None,
"rekey_to": encoding.encode_address(d["rekey"])
if "rekey" in d
else None,
"rekey_to": (
encoding.encode_address(d["rekey"]) if "rekey" in d else None
),
}
txn_type = d["type"]
if not isinstance(d["type"], str):
Expand Down Expand Up @@ -394,13 +394,15 @@ def dictify(self):
@staticmethod
def _undictify(d):
args = {
"close_remainder_to": encoding.encode_address(d["close"])
if "close" in d
else None,
"close_remainder_to": (
encoding.encode_address(d["close"]) if "close" in d else None
),
"amt": d["amt"] if "amt" in d else 0,
"receiver": encoding.encode_address(d["rcv"])
if "rcv" in d
else constants.ZERO_ADDRESS,
"receiver": (
encoding.encode_address(d["rcv"])
if "rcv" in d
else constants.ZERO_ADDRESS
),
}
return args

Expand Down Expand Up @@ -1169,7 +1171,6 @@ def __init__(


class AssetFreezeTxn(Transaction):

"""
Represents a transaction for freezing or unfreezing an account's asset
holdings. Must be issued by the asset's freeze manager.
Expand Down Expand Up @@ -1367,17 +1368,19 @@ def dictify(self):
@staticmethod
def _undictify(d):
args = {
"receiver": encoding.encode_address(d["arcv"])
if "arcv" in d
else constants.ZERO_ADDRESS,
"receiver": (
encoding.encode_address(d["arcv"])
if "arcv" in d
else constants.ZERO_ADDRESS
),
"amt": d["aamt"] if "aamt" in d else 0,
"index": d["xaid"] if "xaid" in d else None,
"close_assets_to": encoding.encode_address(d["aclose"])
if "aclose" in d
else None,
"revocation_target": encoding.encode_address(d["asnd"])
if "asnd" in d
else None,
"close_assets_to": (
encoding.encode_address(d["aclose"]) if "aclose" in d else None
),
"revocation_target": (
encoding.encode_address(d["asnd"]) if "asnd" in d else None
),
}

return args
Expand Down Expand Up @@ -1685,22 +1688,24 @@ def _undictify(d):
args = {
"index": d["apid"] if "apid" in d else None,
"on_complete": d["apan"] if "apan" in d else None,
"local_schema": StateSchema.undictify(d["apls"])
if "apls" in d
else None,
"global_schema": StateSchema.undictify(d["apgs"])
if "apgs" in d
else None,
"local_schema": (
StateSchema.undictify(d["apls"]) if "apls" in d else None
),
"global_schema": (
StateSchema.undictify(d["apgs"]) if "apgs" in d else None
),
"approval_program": d["apap"] if "apap" in d else None,
"clear_program": d["apsu"] if "apsu" in d else None,
"app_args": d["apaa"] if "apaa" in d else None,
"accounts": d["apat"] if "apat" in d else None,
"foreign_apps": d["apfa"] if "apfa" in d else None,
"foreign_assets": d["apas"] if "apas" in d else None,
"extra_pages": d["apep"] if "apep" in d else 0,
"boxes": [BoxReference.undictify(box) for box in d["apbx"]]
if "apbx" in d
else None,
"boxes": (
[BoxReference.undictify(box) for box in d["apbx"]]
if "apbx" in d
else None
),
}
if args["accounts"]:
args["accounts"] = [
Expand Down Expand Up @@ -2303,9 +2308,9 @@ def merge(
for s in range(len(stx.multisig.subsigs)):
if stx.multisig.subsigs[s].signature:
if not msigstx.multisig.subsigs[s].signature:
msigstx.multisig.subsigs[
s
].signature = stx.multisig.subsigs[s].signature
msigstx.multisig.subsigs[s].signature = (
stx.multisig.subsigs[s].signature
)
elif (
not msigstx.multisig.subsigs[s].signature
== stx.multisig.subsigs[s].signature
Expand Down
8 changes: 8 additions & 0 deletions algosdk/v2client/algod.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ def block_info(
block: Optional[int] = None,
response_format: str = "json",
round_num: Optional[int] = None,
header_only: Optional[bool] = None,
**kwargs: Any,
) -> AlgodResponseType:
"""
Expand All @@ -280,8 +281,15 @@ def block_info(
response_format (str): the format in which the response is
returned: either "json" or "msgpack"
round_num (int, optional): alias for block; specify one of these
header_only (bool, optional): if set to true, only block header would be
present in the the response
"""
query = {"format": response_format}

if header_only:
query["header-only"] = "true"

req = "/blocks/" + _specify_round_string(block, round_num)
res = self.algod_request(
"GET", req, query, response_format=response_format, **kwargs
Expand Down
58 changes: 58 additions & 0 deletions algosdk/v2client/indexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,64 @@ def search_transactions(

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

def search_block_headers(
self,
limit=None,
next_page=None,
min_round=None,
max_round=None,
start_time=None,
end_time=None,
proposers=None,
absent=None,
expired=None,
**kwargs
):
"""
Return a list of block headers satisfying the conditions.
Args:
limit (int, optional): maximum number of results to return
next_page (str, optional): the next page of results; use the next
token provided by the previous results
min_round (int, optional): include results at or after the
specified round
max_round (int, optional): include results at or before the
specified round
start_time (str, optional): include results after the given time;
must be an RFC 3339 formatted string
end_time (str, optional): include results before the given time;
must be an RFC 3339 formatted string
proposers (list, optional): include results with accounts marked as
proposers in the block header's participation updates
expired (list, optional): include results with accounts marked as
expired in the block header's participation updates
absent (list, optional): include results with accounts marked as
absent in the block header's participation updates
"""
req = "/block-headers"
query = dict()
if limit:
query["limit"] = limit
if next_page:
query["next"] = next_page
if min_round:
query["min-round"] = min_round
if max_round:
query["max-round"] = max_round
if end_time:
query["before-time"] = end_time
if start_time:
query["after-time"] = start_time
if proposers:
query["proposers"] = proposers
if expired:
query["expired"] = expired
if absent:
query["absent"] = absent

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

def search_transactions_by_address(
self,
address,
Expand Down
8 changes: 5 additions & 3 deletions algosdk/v2client/models/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -504,9 +504,11 @@ def dictify(self):
elif isinstance(value, dict):
result[oas_attr] = dict(
map(
lambda item: (item[0], item[1].dictify())
if hasattr(item[1], "dictify")
else item,
lambda item: (
(item[0], item[1].dictify())
if hasattr(item[1], "dictify")
else item
),
value.items(),
)
)
Expand Down
8 changes: 5 additions & 3 deletions algosdk/v2client/models/account_participation.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,11 @@ def dictify(self):
elif isinstance(value, dict):
result[oas_attr] = dict(
map(
lambda item: (item[0], item[1].dictify())
if hasattr(item[1], "dictify")
else item,
lambda item: (
(item[0], item[1].dictify())
if hasattr(item[1], "dictify")
else item
),
value.items(),
)
)
Expand Down
8 changes: 5 additions & 3 deletions algosdk/v2client/models/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,11 @@ def dictify(self):
elif isinstance(value, dict):
result[oas_attr] = dict(
map(
lambda item: (item[0], item[1].dictify())
if hasattr(item[1], "dictify")
else item,
lambda item: (
(item[0], item[1].dictify())
if hasattr(item[1], "dictify")
else item
),
value.items(),
)
)
Expand Down
8 changes: 5 additions & 3 deletions algosdk/v2client/models/application_local_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,11 @@ def dictify(self):
elif isinstance(value, dict):
result[oas_attr] = dict(
map(
lambda item: (item[0], item[1].dictify())
if hasattr(item[1], "dictify")
else item,
lambda item: (
(item[0], item[1].dictify())
if hasattr(item[1], "dictify")
else item
),
value.items(),
)
)
Expand Down
8 changes: 5 additions & 3 deletions algosdk/v2client/models/application_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,11 @@ def dictify(self):
elif isinstance(value, dict):
result[oas_attr] = dict(
map(
lambda item: (item[0], item[1].dictify())
if hasattr(item[1], "dictify")
else item,
lambda item: (
(item[0], item[1].dictify())
if hasattr(item[1], "dictify")
else item
),
value.items(),
)
)
Expand Down
8 changes: 5 additions & 3 deletions algosdk/v2client/models/application_state_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,11 @@ def dictify(self):
elif isinstance(value, dict):
result[oas_attr] = dict(
map(
lambda item: (item[0], item[1].dictify())
if hasattr(item[1], "dictify")
else item,
lambda item: (
(item[0], item[1].dictify())
if hasattr(item[1], "dictify")
else item
),
value.items(),
)
)
Expand Down
8 changes: 5 additions & 3 deletions algosdk/v2client/models/asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,11 @@ def dictify(self):
elif isinstance(value, dict):
result[oas_attr] = dict(
map(
lambda item: (item[0], item[1].dictify())
if hasattr(item[1], "dictify")
else item,
lambda item: (
(item[0], item[1].dictify())
if hasattr(item[1], "dictify")
else item
),
value.items(),
)
)
Expand Down
8 changes: 5 additions & 3 deletions algosdk/v2client/models/asset_holding.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,11 @@ def dictify(self):
elif isinstance(value, dict):
result[oas_attr] = dict(
map(
lambda item: (item[0], item[1].dictify())
if hasattr(item[1], "dictify")
else item,
lambda item: (
(item[0], item[1].dictify())
if hasattr(item[1], "dictify")
else item
),
value.items(),
)
)
Expand Down
8 changes: 5 additions & 3 deletions algosdk/v2client/models/asset_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,9 +389,11 @@ def dictify(self):
elif isinstance(value, dict):
result[oas_attr] = dict(
map(
lambda item: (item[0], item[1].dictify())
if hasattr(item[1], "dictify")
else item,
lambda item: (
(item[0], item[1].dictify())
if hasattr(item[1], "dictify")
else item
),
value.items(),
)
)
Expand Down
Loading

0 comments on commit 1c5a4c3

Please sign in to comment.