Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: accept address or index param for VoterParamsGet methods #369

Merged
merged 1 commit into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion langspec.puya.json
Original file line number Diff line number Diff line change
Expand Up @@ -6889,7 +6889,7 @@
"stack_inputs": [
{
"name": "A",
"stack_type": "any",
"stack_type": "address_or_index",
"doc": null
}
],
Expand Down
1 change: 1 addition & 0 deletions scripts/transform_lang_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ def _patch_lang_spec(lang_spec: dict[str, typing.Any]) -> None:
"asset_holding_get",
"balance",
"min_balance",
"voter_params_get",
):
_patch_arg_type(ops, op_name, 0, "any", "address_or_index")

Expand Down
5 changes: 3 additions & 2 deletions src/puya/ir/avm_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -6258,15 +6258,16 @@ def get_variant(self, immediates: Sequence[str | int]) -> Variant:
variant_map={
"VoterBalance": Variant(
signature=OpSignature(
args=[StackType.any], returns=[StackType.uint64, StackType.bool]
args=[StackType.address_or_index],
returns=[StackType.uint64, StackType.bool],
),
enum="VoterBalance",
supported_modes=RunMode.app,
min_avm_version=6,
),
"VoterIncentiveEligible": Variant(
signature=OpSignature(
args=[StackType.any], returns=[StackType.bool, StackType.bool]
args=[StackType.address_or_index], returns=[StackType.bool, StackType.bool]
),
enum="VoterIncentiveEligible",
supported_modes=RunMode.app,
Expand Down
4 changes: 2 additions & 2 deletions src/puyapy/awst_build/intrinsic_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -5382,7 +5382,7 @@
FunctionOpMapping(
"voter_params_get",
immediates=["VoterBalance"],
args=[(pytypes.BytesType, pytypes.UInt64Type)],
args=[(pytypes.AccountType, pytypes.UInt64Type)],
),
],
),
Expand All @@ -5395,7 +5395,7 @@
FunctionOpMapping(
"voter_params_get",
immediates=["VoterIncentiveEligible"],
args=[(pytypes.BytesType, pytypes.UInt64Type)],
args=[(pytypes.AccountType, pytypes.UInt64Type)],
),
],
),
Expand Down
4 changes: 2 additions & 2 deletions stubs/algopy-stubs/op.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3864,7 +3864,7 @@ class VoterParamsGet:
Native TEAL op: [`voter_params_get`](https://developer.algorand.org/docs/get-details/dapps/avm/teal/opcodes/v10/#voter_params_get)
"""
@staticmethod
def voter_balance(a: Bytes | UInt64 | bytes | int, /) -> tuple[UInt64, bool]:
def voter_balance(a: Account | UInt64 | int, /) -> tuple[UInt64, bool]:
"""
Min AVM version: 11
:returns tuple[UInt64, bool]: Online stake in microalgos
Expand All @@ -3873,7 +3873,7 @@ class VoterParamsGet:
"""

@staticmethod
def voter_incentive_eligible(a: Bytes | UInt64 | bytes | int, /) -> tuple[bool, bool]:
def voter_incentive_eligible(a: Account | UInt64 | int, /) -> tuple[bool, bool]:
"""
Min AVM version: 11
:returns tuple[bool, bool]: Had this account opted into block payouts
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 = "2.4.0"
version = "2.4.1"
description = "API for writing Algorand Python Smart contracts"
authors = ["Algorand Foundation <[email protected]>"]
readme = "README.md"
Expand Down
Loading