Skip to content

Commit

Permalink
Merge branch 'master' into avm8
Browse files Browse the repository at this point in the history
  • Loading branch information
ahangsu committed Aug 15, 2022
2 parents bc78e39 + d4c1df3 commit 2c2b7b2
Show file tree
Hide file tree
Showing 19 changed files with 107 additions and 243 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
# Unreleased

# 0.16.0

## Added
* Add the ability to pass foreign reference arrays directly into inner transactions ([#384](https://github.com/algorand/pyteal/pull/384))

* NamedTuple Implementation ([#473](https://github.com/algorand/pyteal/pull/473))

* ExecuteMethodCall helper ([#501](https://github.com/algorand/pyteal/pull/501))

## Fixed

* CI: Fail readthedocs build on warning ([#478](https://github.com/algorand/pyteal/pull/478))

* Windows Compatibility ([#499](https://github.com/algorand/pyteal/pull/499))

## Changed
* Update `Block` docs to match spec change ([#503](https://github.com/algorand/pyteal/pull/503))

# 0.15.0

## Added
* Support AVM 7 updates:
* New opcodes:
Expand Down
8 changes: 4 additions & 4 deletions pyteal/ast/block.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ def seed(cls, block: Expr) -> Expr:
Args:
block: A block index that corresponds to the block to check,
must be evaluated to uint64. Fails if the block index is not less than the
current round or more than 1001 rounds before txn.LastValid.
must be evaluated to uint64. Fails if the block index is not less than
:code:`Txn.first_valid()` or more than 1001 rounds before :code:`Txn.last_valid()`.
"""
return cls(BlockField.block_seed, block)

Expand All @@ -71,8 +71,8 @@ def timestamp(cls, block: Expr) -> Expr:
Args:
block: A block index that corresponds to the block to check,
must be evaluated to uint64. Fails if the block index is not less than the
current round or more than 1001 rounds before txn.LastValid.
must be evaluated to uint64. Fails if the block index is not less than
:code:`Txn.first_valid()` or more than 1001 rounds before :code:`Txn.last_valid()`.
"""
return cls(BlockField.block_timestamp, block)

Expand Down
63 changes: 60 additions & 3 deletions pyteal/ast/itxn.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ def Execute(cls, fields: dict[TxnField, Expr | list[Expr]]) -> Expr:
InnerTxnBuilder.Begin()
InnerTxnBuilder.SetFields(fields)
InnerTxnBuilder.End()
InnerTxnBuilder.Submit()
Requires program version 5 or higher. This operation is only permitted in application mode.
Expand Down Expand Up @@ -249,14 +249,71 @@ def SetFields(cls, fields: dict[TxnField, Expr | list[Expr]]) -> Expr:
fieldsToSet = [cls.SetField(field, value) for field, value in fields.items()]
return Seq(fieldsToSet)

@classmethod
def ExecuteMethodCall(
cls,
*,
app_id: Expr,
method_signature: str,
args: list[abi.BaseType | Expr | dict[TxnField, Expr | list[Expr]]],
extra_fields: dict[TxnField, Expr | list[Expr]] = None,
) -> Expr:
"""Performs a single app call transaction formatted as an ABI method call.
A convenience method that accepts fields to submit a single inner transaction, which is equivalent to:
.. code-block:: python
InnerTxnBuilder.Begin()
InnerTxnBuilder.MethodCall(
app_id=app_id,
method_signature=method_signature,
args=args,
extra_fields=extra_fields,
),
InnerTxnBuilder.Submit()
Requires program version 5 or higher. This operation is only permitted in application mode.
Args:
app_id: An expression that evaluates to a `TealType.uint64` corresponding to the application being called.
method_signature: A string representing the method signature of the method we're calling. This is used to do
type checking on the arguments passed and to create the method selector passed as the first argument.
args: A list of arguments to pass to the application. The values in this list depend on the kind of argument you wish to pass:
- For basic ABI arguments (not Reference or Transaction types):
If an ABI type is passed it **MUST** match the type specified in the `method_signature`. If an Expr is passed it must evaluate to `TealType.bytes` but beyond that no type checking is performed.
- For Reference arguments:
Either the Reference type or an Expr that returns the type corresponding to the reference type are allowed.
(i.e. Asset is TealType.uint64, Application is TealType.uint64, Account is TealType.bytes)
- For Transaction arguments:
A dictionary containing TxnField to Expr that describe Transactions to be pre-pended to the transaction group being constructed. The `TxnField.type_enum` key MUST be set and MUST match the expected transaction type specified in the `method_signature`.
extra_fields (optional): A dictionary whose keys are fields to set and whose values are the value each
field should take. Each value must evaluate to a type that is compatible with the
field being set. These fields are set on the ApplicationCallTransaction being constructed
"""
return Seq(
cls.Begin(),
cls.MethodCall(
app_id=app_id,
method_signature=method_signature,
args=args,
extra_fields=extra_fields,
),
cls.Submit(),
)

@classmethod
def MethodCall(
cls,
*,
app_id: Expr,
method_signature: str,
args: list[abi.BaseType | Expr | dict[TxnField, Expr | list[Expr]]],
extra_fields: dict[TxnField, Expr | list[Expr]] = {},
extra_fields: dict[TxnField, Expr | list[Expr]] = None,
) -> Expr:
"""Adds an ABI method call transaction to the current inner transaction group.
Expand Down Expand Up @@ -425,7 +482,7 @@ def MethodCall(
# Set the fields for the app call in app args and foreign arrays
*fields_to_set,
# Add any remaining fields specified by the user
InnerTxnBuilder.SetFields(extra_fields),
InnerTxnBuilder.SetFields({} if extra_fields is None else extra_fields),
)


Expand Down
Loading

0 comments on commit 2c2b7b2

Please sign in to comment.