Skip to content

Commit 0714178

Browse files
authored
Release/v1.4.0 beta (#138)
Review: #138
1 parent ae081ba commit 0714178

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+6136
-217
lines changed

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
2-
## 1.3.0
2+
## 1.4.0
3+
## Added
4+
- Support for Applications
5+
## Bugfix
6+
- Now content-type is set when sending transactions
7+
- indexer client now allows no token for local development environment
8+
39
### Added
410
- Support for indexer and algod 2.0
511

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
unit:
2-
behave --tags="@unit.offline or @unit.algod or @unit.indexer" test -f progress2
2+
behave --tags="@unit.offline or @unit.algod or @unit.indexer or @unit.rekey or @unit.tealsign or @unit.dryrun or @unit.responses" test -f progress2
33

44
integration:
5-
behave --tags="@algod or @assets or @auction or @kmd or @send or @template or @indexer" test -f progress2
5+
behave --tags="@algod or @assets or @auction or @kmd or @send or @template or @indexer or @indexer.applications or @rekey or @compile or @dryrun or @dryrun.testing or @applications or @applications.verified" test -f progress2
66

77
docker-test:
88
./run_integration.sh

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,16 @@ txn = transaction.AssetTransferTxn(clawback_address, sp,
500500
signed_txn = txn.sign(clawback_private_key)
501501
```
502502

503+
## Rekeying
504+
To rekey an account to a new address, add the `rekey_to` argument to creation.
505+
```python
506+
...
507+
# After sending rekeying_txn, every transaction needs to be signed by the SK of the following address
508+
rekey_address = "47YPQTIGQEO7T4Y4RWDYWEKV6RTR2UNBQXBABEEGM72ESWDQNCQ52OPASU"
509+
rekeying_txn = transaction.PaymentTxn(sender, sp, receiver, amount, rekey_to=rekey_address)
510+
...
511+
```
512+
503513
## Documentation
504514
Documentation for the Python SDK is available at [py-algorand-sdk.readthedocs.io](https://py-algorand-sdk.readthedocs.io/en/latest/).
505515

algosdk/algod.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,9 +251,10 @@ def suggested_params_as_object(self, **kwargs):
251251
res["genesisID"],
252252
False)
253253

254-
def send_raw_transaction(self, txn, **kwargs):
254+
def send_raw_transaction(self, txn, headers=None, **kwargs):
255255
"""
256256
Broadcast a signed transaction to the network.
257+
Sets the default Content-Type header, if not previously set.
257258
258259
Args:
259260
txn (str): transaction to send, encoded in base64
@@ -262,9 +263,12 @@ def send_raw_transaction(self, txn, **kwargs):
262263
Returns:
263264
str: transaction ID
264265
"""
266+
tx_headers = dict(headers) if headers is not None else {}
267+
if all(map(lambda x: x.lower() != "content-type", [*tx_headers])):
268+
tx_headers['Content-Type'] = 'application/x-binary'
265269
txn = base64.b64decode(txn)
266270
req = "/transactions"
267-
return self.algod_request("POST", req, data=txn, **kwargs)["txId"]
271+
return self.algod_request("POST", req, data=txn, headers=tx_headers, **kwargs)["txId"]
268272

269273
def send_transaction(self, txn, **kwargs):
270274
"""

algosdk/constants.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
"""str: indicates an asset freeze transaction"""
2626
assettransfer_txn = "axfer"
2727
"""str: indicates an asset transfer transaction"""
28+
appcall_txn = "appl"
29+
"""str: indicates an app call transaction, allows creating, deleting, and interacting with an application"""
2830

2931
# note field types
3032
note_field_type_deposit = "d"
@@ -36,7 +38,6 @@
3638
note_field_type_params = "p"
3739
"""str: indicates signed params in NoteField"""
3840

39-
4041
# prefixes
4142
txid_prefix = b"TX"
4243
"""bytes: transaction prefix when signing"""
@@ -50,6 +51,8 @@
5051
"""str: prefix for multisig addresses"""
5152
logic_prefix = b"Program"
5253
"""bytes: program (logic) prefix when signing"""
54+
logic_data_prefix = b"ProgData"
55+
"""bytes: program (logic) data prefix when signing"""
5356

5457

5558
check_sum_len_bytes = 4
@@ -66,6 +69,8 @@
6669
"""int: how many microalgos per algo"""
6770
metadata_length = 32
6871
"""int: length of asset metadata"""
72+
note_max_length = 1024
73+
"""int: maximum length of note field"""
6974
lease_length = 32
7075
"""int: byte length of leases"""
7176
multisig_account_limit = 255

algosdk/data/langspec.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

algosdk/encoding.py

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import msgpack
33
from collections import OrderedDict
44
from Cryptodome.Hash import SHA512
5-
from . import transaction, error, auction, constants
5+
from . import transaction, error, auction, constants, future
66

77

88
def msgpack_encode(obj):
@@ -52,6 +52,43 @@ def _sort_dict(d):
5252
return od
5353

5454

55+
def future_msgpack_decode(enc):
56+
"""
57+
Decode a msgpack encoded object from a string.
58+
59+
Args:
60+
enc (str): string to be decoded
61+
62+
Returns:
63+
Transaction, SignedTransaction, Multisig, Bid, or SignedBid:\
64+
decoded object
65+
"""
66+
decoded = enc
67+
if not isinstance(enc, dict):
68+
decoded = msgpack.unpackb(base64.b64decode(enc), raw=False)
69+
if "type" in decoded:
70+
return future.transaction.Transaction.undictify(decoded)
71+
if "l" in decoded:
72+
return future.transaction.LogicSig.undictify(decoded)
73+
if "msig" in decoded:
74+
return future.transaction.MultisigTransaction.undictify(decoded)
75+
if "lsig" in decoded:
76+
return future.transaction.LogicSigTransaction.undictify(decoded)
77+
if "sig" in decoded:
78+
return future.transaction.SignedTransaction.undictify(decoded)
79+
if "txn" in decoded:
80+
return future.transaction.Transaction.undictify(decoded["txn"])
81+
if "subsig" in decoded:
82+
return future.transaction.Multisig.undictify(decoded)
83+
if "txlist" in decoded:
84+
return future.transaction.TxGroup.undictify(decoded)
85+
if "t" in decoded:
86+
return auction.NoteField.undictify(decoded)
87+
if "bid" in decoded:
88+
return auction.SignedBid.undictify(decoded)
89+
if "auc" in decoded:
90+
return auction.Bid.undictify(decoded)
91+
5592
def msgpack_decode(enc):
5693
"""
5794
Decode a msgpack encoded object from a string.

algosdk/error.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ def __init__(self):
2525
Exception.__init__(self, "mismatched duplicate signatures in multisig")
2626

2727

28+
class WrongAmountType(Exception):
29+
def __init(self):
30+
Exception.__init__(self, "amount (amt) must be a non-negative integer")
31+
32+
2833
class WrongChecksumError(Exception):
2934
def __init__(self):
3035
Exception.__init__(self, "checksum failed to validate")
@@ -60,6 +65,16 @@ def __init(self):
6065
Exception.__init__(self, "lease length must be 32 bytes")
6166

6267

68+
class WrongNoteType(Exception):
69+
def __init(self):
70+
Exception.__init__(self, "note must be of type \"bytes\"")
71+
72+
73+
class WrongNoteLength(Exception):
74+
def __init(self):
75+
Exception.__init__(self, "note length must be at most 1024")
76+
77+
6378
class InvalidProgram(Exception):
6479
def __init__(self, message="invalid program for logic sig"):
6580
Exception.__init__(self, message)
@@ -109,7 +124,9 @@ class KMDHTTPError(Exception):
109124

110125

111126
class AlgodHTTPError(Exception):
112-
pass
127+
def __init__(self, msg, code=None):
128+
super().__init__(msg)
129+
self.code = code
113130

114131
class IndexerHTTPError(Exception):
115132
pass

0 commit comments

Comments
 (0)