Skip to content

Commit

Permalink
fix: use correct return type for algopy.op.gaid
Browse files Browse the repository at this point in the history
BREAKING CHANGE:
`algop.op.gaid` return type has changed from `algopy.Application` to `algopy.UInt64` as the return value could be the id of either an application or an asset. Any existing usages of `algopy.op.gaid` will need to pass the result to either `algopy.Application` or `algopy.Asset` as appropriate
  • Loading branch information
daniel-makerx authored and achidlow committed Aug 16, 2024
1 parent 5663a55 commit a5c57ef
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 17 deletions.
4 changes: 2 additions & 2 deletions langspec.puya.json
Original file line number Diff line number Diff line change
Expand Up @@ -4183,7 +4183,7 @@
"stack_outputs": [
{
"name": "X",
"stack_type": "application",
"stack_type": "uint64",
"doc": null
}
]
Expand Down Expand Up @@ -4217,7 +4217,7 @@
"stack_outputs": [
{
"name": "X",
"stack_type": "application",
"stack_type": "uint64",
"doc": null
}
]
Expand Down
8 changes: 0 additions & 8 deletions scripts/transform_lang_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,14 +269,6 @@ def _patch_lang_spec(lang_spec: dict[str, typing.Any]) -> None:
}.items():
_patch_arg_type(ops, op_name, arg_index, "uint64", "application")

# patch ops that use a stack type of uint64
# for return types that should be an Application
for op_name in [
"gaid",
"gaids",
]:
_patch_return_type(ops, op_name, 0, "uint64", "application")

# patch ops that use a stack type of uint64
# for return types that should be a bool
for op_name in [
Expand Down
2 changes: 1 addition & 1 deletion src/puya/awst_build/intrinsic_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@
],
),
gaid=OpMappingWithOverloads(
result=pytypes.ApplicationType,
result=pytypes.UInt64Type,
arity=1,
overloads=[
FunctionOpMapping(
Expand Down
2 changes: 1 addition & 1 deletion src/puya/compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@

# this should contain the lowest version number that this compiler does NOT support
# i.e. the next minor version after what is defined in stubs/pyproject.toml:tool.poetry.version
MAX_SUPPORTED_ALGOPY_VERSION_EX = version.parse("1.4.0")
MAX_SUPPORTED_ALGOPY_VERSION_EX = version.parse("2.1.0")
MIN_SUPPORTED_ALGOPY_VERSION = version.parse(f"{MAX_SUPPORTED_ALGOPY_VERSION_EX.major}.0.0")

logger = log.get_logger(__name__)
Expand Down
5 changes: 2 additions & 3 deletions src/puya/ir/avm_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -1657,8 +1657,7 @@ def get_variant(self, immediates: Sequence[str | int]) -> Variant:
gaid = AVMOpData(
op_code="gaid",
variants=Variant(
signature=OpSignature(args=[], returns=[StackType.application]),
supported_modes=RunMode.app,
signature=OpSignature(args=[], returns=[StackType.uint64]), supported_modes=RunMode.app
),
immediate_types=(ImmediateKind.uint8,),
cost=1,
Expand All @@ -1675,7 +1674,7 @@ def get_variant(self, immediates: Sequence[str | int]) -> Variant:
gaids = AVMOpData(
op_code="gaids",
variants=Variant(
signature=OpSignature(args=[StackType.uint64], returns=[StackType.application]),
signature=OpSignature(args=[StackType.uint64], returns=[StackType.uint64]),
supported_modes=RunMode.app,
),
immediate_types=(),
Expand Down
2 changes: 1 addition & 1 deletion stubs/algopy-stubs/op.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ def extract_uint64(a: Bytes | bytes, b: UInt64 | int, /) -> UInt64:
Native TEAL opcode: [`extract_uint64`](https://developer.algorand.org/docs/get-details/dapps/avm/teal/opcodes/v10/#extract_uint64)
"""

def gaid(a: UInt64 | int, /) -> Application:
def gaid(a: UInt64 | int, /) -> UInt64:
"""
ID of the asset or application created in the Ath transaction of the current group
`gaids` fails unless the requested transaction created an asset or application and A < GroupIndex.
Expand Down
2 changes: 1 addition & 1 deletion stubs/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "algorand-python"
# this version represents the version of the stub API's and should follow semver semantics
# when updating this value also update src/compile.py:MAX_SUPPORTED_ALGOPY_VERSION_EX if it is a major/minor change
# also see stubs/README.md#versioning
version = "1.3.0"
version = "2.0.0"
description = "API for writing Algorand Python Smart contracts"
authors = ["Algorand Foundation <contact@algorand.foundation>"]
readme = "README.md"
Expand Down

0 comments on commit a5c57ef

Please sign in to comment.