Skip to content

Commit 059b669

Browse files
committed
feat: update algopy.op.AcctParamsGet with fields added in AVM 11
1 parent fc53b0f commit 059b669

File tree

4 files changed

+55
-1
lines changed

4 files changed

+55
-1
lines changed

src/_algopy_testing/models/account.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ class AccountFields(typing.TypedDict, total=False):
3030
total_assets: algopy.UInt64
3131
total_boxes: algopy.UInt64
3232
total_box_bytes: algopy.UInt64
33+
incentive_eligible: bool
34+
last_heartbeat: algopy.UInt64
35+
last_proposed: algopy.UInt64
3336

3437

3538
def get_empty_account() -> AccountContextData:
@@ -47,6 +50,9 @@ def get_empty_account() -> AccountContextData:
4750
"total_assets": UInt64(),
4851
"total_boxes": UInt64(),
4952
"total_box_bytes": UInt64(),
53+
"incentive_eligible": False,
54+
"last_heartbeat": UInt64(),
55+
"last_proposed": UInt64(),
5056
},
5157
)
5258

src/_algopy_testing/op/misc.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,27 @@ def acct_total_box_bytes(
188188
account = _get_account(a)
189189
return account.total_box_bytes, account.balance != 0
190190

191+
@staticmethod
192+
def acct_incentive_eligible(
193+
a: algopy.Account | algopy.UInt64 | int,
194+
) -> tuple[bool, bool]:
195+
account = _get_account(a)
196+
return account.incentive_eligible, account.balance != 0
197+
198+
@staticmethod
199+
def acct_last_heartbeat(
200+
a: algopy.Account | algopy.UInt64 | int,
201+
) -> tuple[algopy.UInt64, bool]:
202+
account = _get_account(a)
203+
return account.last_heartbeat, account.balance != 0
204+
205+
@staticmethod
206+
def acct_last_proposed(
207+
a: algopy.Account | algopy.UInt64 | int,
208+
) -> tuple[algopy.UInt64, bool]:
209+
account = _get_account(a)
210+
return account.last_proposed, account.balance != 0
211+
191212

192213
class AssetParamsGet:
193214
@staticmethod

tests/artifacts/StateOps/contract.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def _get_1st_ref_index() -> UInt64:
2121
return op.btoi(Txn.application_args(1))
2222

2323

24-
class StateAcctParamsGetContract(ARC4Contract):
24+
class StateAcctParamsGetContract(ARC4Contract, avm_version=11):
2525
@arc4.abimethod()
2626
def verify_acct_balance(self, a: algopy.Account) -> algopy.UInt64:
2727
value, funded = op.AcctParamsGet.acct_balance(a)
@@ -134,6 +134,30 @@ def verify_acct_total_box_bytes(self, a: algopy.Account) -> algopy.UInt64:
134134
assert funded == funded_index, "expected funded by index to match"
135135
return value
136136

137+
@arc4.abimethod()
138+
def verify_acct_incentive_eligible(self, a: algopy.Account) -> bool:
139+
value, funded = op.AcctParamsGet.acct_incentive_eligible(a)
140+
value_index, funded_index = op.AcctParamsGet.acct_incentive_eligible(_get_1st_ref_index())
141+
assert value == value_index, "expected value by index to match"
142+
assert funded == funded_index, "expected funded by index to match"
143+
return value
144+
145+
@arc4.abimethod()
146+
def verify_acct_last_heartbeat(self, a: algopy.Account) -> algopy.UInt64:
147+
value, funded = op.AcctParamsGet.acct_last_heartbeat(a)
148+
value_index, funded_index = op.AcctParamsGet.acct_last_heartbeat(_get_1st_ref_index())
149+
assert value == value_index, "expected value by index to match"
150+
assert funded == funded_index, "expected funded by index to match"
151+
return value
152+
153+
@arc4.abimethod()
154+
def verify_acct_last_proposed(self, a: algopy.Account) -> algopy.UInt64:
155+
value, funded = op.AcctParamsGet.acct_last_proposed(a)
156+
value_index, funded_index = op.AcctParamsGet.acct_last_proposed(_get_1st_ref_index())
157+
assert value == value_index, "expected value by index to match"
158+
assert funded == funded_index, "expected funded by index to match"
159+
return value
160+
137161

138162
class StateAssetHoldingContract(ARC4Contract):
139163
@arc4.abimethod()

tests/test_op.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,9 @@ def test_app_params_get(
563563
("verify_acct_total_assets", 0),
564564
("verify_acct_total_boxes", 0),
565565
("verify_acct_total_box_bytes", 0),
566+
("verify_acct_incentive_eligible", False),
567+
("verify_acct_last_heartbeat", 0),
568+
("verify_acct_last_proposed", 0),
566569
],
567570
)
568571
def test_acct_params_get(

0 commit comments

Comments
 (0)