Skip to content

Commit

Permalink
Merge branch 'release/v1.9.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
algobarb committed Jan 14, 2022
2 parents 6bb2533 + 3b389a9 commit 1e4990f
Show file tree
Hide file tree
Showing 3 changed files with 145 additions and 6 deletions.
24 changes: 20 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# Changelog

## 1.9.0
### Added

- Create dryrun (#259)
- Support Foreign objects as ABI arguments and address ARC-4 changes (#251)
- Add requirement to fetch behave source code and update readme (#262)
- Fix wait for confirmation function (#263)
- Add a default User-Agent header to the v2 algod client (#260)
- ABI Interaction Support for Python SDK (#247)
- ABI Type encoding support (#238)
- Add type hints and clean up ABI code (#253)
- Add CircleCI configs to the Python SDK repo (#246)

### Changed
- Re-format local and global state to work with correct msgpack encoding (#274)

## 1.9.0b2
### Added

Expand Down Expand Up @@ -77,7 +93,7 @@

## 1.4.0
## Added
- Support for Applications
- Support for Applications
## Bugfix
- Now content-type is set when sending transactions
- indexer client now allows no token for local development environment
Expand All @@ -87,7 +103,7 @@

## 1.2.0
### Added
- Added support for Algorand Smart Contracts (ASC)
- Added support for Algorand Smart Contracts (ASC)
- Dynamic fee contract
- Limit order contract
- Periodic payment contract
Expand All @@ -101,8 +117,8 @@
## 1.1.0
### Added
- Added support for Algorand Standardized Assets (ASA)
- Added support for Algorand Smart Contracts (ASC)
- Added support for Hashed Time Lock Contract (HTLC)
- Added support for Algorand Smart Contracts (ASC)
- Added support for Hashed Time Lock Contract (HTLC)
- Added support for Split contract
- Added support for Group Transactions
- Added support for leases
Expand Down
125 changes: 124 additions & 1 deletion algosdk/future/transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from .. import error
from .. import logic
from .. import transaction
from ..v2client import algod
from ..v2client import algod, models
from nacl.signing import SigningKey, VerifyKey
from nacl.exceptions import BadSignatureError

Expand Down Expand Up @@ -3062,3 +3062,126 @@ def wait_for_confirmation(

# Incremenent the `current_round`
current_round += 1


defaultAppId = 1380011588


def create_dryrun(
client: algod.AlgodClient,
txns: List[Union[SignedTransaction, LogicSigTransaction]],
protocol_version=None,
latest_timestamp=None,
round=None,
) -> models.DryrunRequest:
"""
Create DryrunRequest object from a client and list of signed transactions

Args:
algod_client (algod.AlgodClient): Instance of the `algod` client
txns (List[SignedTransaction]): transaction ID
protocol_version (string, optional): The protocol version to evaluate against
latest_timestamp (int, optional): The latest timestamp to evaluate against
round (int, optional): The round to evaluate against
"""

# The list of info objects passed to the DryrunRequest object
app_infos, acct_infos = [], []

# The running list of things we need to fetch
apps, assets, accts = [], [], []
for t in txns:
txn = t.transaction

# we only care about app call transactions
if issubclass(type(txn), ApplicationCallTxn):
accts.append(txn.sender)

# Add foreign args if they're set
if txn.accounts:
accts.extend(txn.accounts)
if txn.foreign_apps:
apps.extend(txn.foreign_apps)
if txn.foreign_assets:
assets.extend(txn.foreign_assets)

# For creates, we need to add the source directly from the transaction
if txn.index == 0:
appId = defaultAppId
# Make up app id, since tealdbg/dryrun doesnt like 0s
# https://github.com/algorand/go-algorand/blob/e466aa18d4d963868d6d15279b1c881977fa603f/libgoal/libgoal.go#L1089-L1090

ls = txn.local_schema
if ls is not None:
ls = models.ApplicationStateSchema(
ls.num_uints, ls.num_byte_slices
)

gs = txn.global_schema
if gs is not None:
gs = models.ApplicationStateSchema(
gs.num_uints, gs.num_byte_slices
)

app_infos.append(
models.Application(
id=appId,
params=models.ApplicationParams(
creator=txn.sender,
approval_program=txn.approval_program,
clear_state_program=txn.clear_program,
local_state_schema=ls,
global_state_schema=gs,
),
)
)
else:
apps.append(txn.index)

# Dedupe and filter none, reset programs to bytecode instead of b64
apps = [i for i in set(apps) if i]
for app in apps:
app_info = client.application_info(app)
# Need to pass bytes, not b64 string
app_info = decode_programs(app_info)
app_infos.append(app_info)

# Make sure the application account is in the accounts array
accts.append(logic.get_application_address(app))

# Dedupe and filter None, add asset creator to accounts to include in dryrun
assets = [i for i in set(assets) if i]
for asset in assets:
asset_info = client.asset_info(asset)

# Make sure the asset creator address is in the accounts array
accts.append(asset_info["params"]["creator"])

# Dedupe and filter None, fetch and add account info
accts = [i for i in set(accts) if i]
for acct in accts:
acct_info = client.account_info(acct)
if "created-apps" in acct_info:
acct_info["created-apps"] = [
decode_programs(ca) for ca in acct_info["created-apps"]
]
acct_infos.append(acct_info)

return models.DryrunRequest(
txns=txns,
apps=app_infos,
accounts=acct_infos,
protocol_version=protocol_version,
latest_timestamp=latest_timestamp,
round=round,
)


def decode_programs(app):
app["params"]["approval-program"] = base64.b64decode(
app["params"]["approval-program"]
)
app["params"]["clear-state-program"] = base64.b64decode(
app["params"]["clear-state-program"]
)
return app
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
description="Algorand SDK in Python",
author="Algorand",
author_email="[email protected]",
version="1.9.0b2",
version="1.9.0",
long_description=long_description,
long_description_content_type="text/markdown",
license="MIT",
Expand Down

0 comments on commit 1e4990f

Please sign in to comment.