Skip to content

Commit 00fe1bc

Browse files
committed
fix: do not allow specifying address for applications, it is derived from the app_id
1 parent 94a989f commit 00fe1bc

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

src/_algopy_testing/models/application.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import typing
44

5+
import algosdk.logic
6+
57
from _algopy_testing.primitives import UInt64
68
from _algopy_testing.protocols import UInt64Backed
79
from _algopy_testing.utils import as_int64
@@ -23,7 +25,6 @@ class ApplicationFields(typing.TypedDict, total=False):
2325
local_num_bytes: algopy.UInt64
2426
extra_program_pages: algopy.UInt64
2527
creator: algopy.Account
26-
address: algopy.Account
2728

2829

2930
AccountKey = str
@@ -57,6 +58,13 @@ def __init__(self, application_id: algopy.UInt64 | int = 0, /):
5758
def id(self) -> algopy.UInt64:
5859
return UInt64(self._id)
5960

61+
@property
62+
def address(self) -> algopy.Account:
63+
from _algopy_testing.models import Account
64+
65+
address = algosdk.logic.get_application_address(self._id)
66+
return Account(address)
67+
6068
@property
6169
def int_(self) -> int:
6270
return self._id

src/_algopy_testing/value_generators/avm.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,9 @@ def asset(
143143
lazy_context.ledger._asset_data[int(new_asset.id)] = AssetFields(**merged_fields) # type: ignore[typeddict-item]
144144
return new_asset
145145

146-
def application( # type: ignore[misc]
146+
def application(
147147
self,
148148
id: int | None = None,
149-
address: algopy.Account | None = None,
150149
logs: list[bytes] | None = None, # type: ignore[valid-type]
151150
**application_fields: typing.Unpack[ApplicationFields],
152151
) -> algopy.Application:
@@ -175,8 +174,6 @@ def application( # type: ignore[misc]
175174
"local_num_bytes": _algopy_testing.UInt64(0),
176175
"extra_program_pages": _algopy_testing.UInt64(0),
177176
"creator": lazy_context.value.default_sender,
178-
"address": address
179-
or _algopy_testing.Account(algosdk.logic.get_application_address(new_app_id)),
180177
}
181178

182179
# Merge provided fields with defaults, prioritizing provided fields

tests/test_op.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,6 @@ def test_app_params_get(
542542
local_num_bytes=algopy.UInt64(0),
543543
extra_program_pages=algopy.UInt64(0),
544544
creator=algopy.Account(get_localnet_default_account(algod_client).address),
545-
address=algopy.Account(client.app_address),
546545
)
547546

548547
contract = StateAppParamsContract()

0 commit comments

Comments
 (0)